/** * @return the message logged. */ @API public String getMessage() { return message; }
/** * Returns the EventHandler that threw the Throwable. * * @return the EventHandler that threw the Throwable. */ @API public EventHandler getThrower() { return handler; }
/** * Sets the level of the current logger. All messages below that level will be ignored. * @param level The level. * @return {@code this}, for using the builder pattern. */ @API public OSLogger setLevel(LogLevel level) { this.level = level; return this; }
/** * Returns the event that made the EventHandler throw the exception. * * @return the event that made the EventHandler throw the exception. */ @API public Object getEvent() { return event; } }
/** * @return the level of the logged message. */ @API public LogLevel getLevel() { return level; }
/** * @return the unhandled event. */ @API public Object getEvent() { return event; } }
/** * Creates a builder for a OSLogger with the given name that prints to the file with the given path. * @param path The path of the file the logger will output to. * @param loggerName The name of the logger. * @throws FileNotFoundException If the file could not be found. */ @API public Builder(String path, String loggerName) throws FileNotFoundException { this(new File(path), loggerName); }
/** * @return an immutable copy of the loggers this multi-logger logs to. */ @API public Set<ILogger> getLoggers() { return ImmutableSet.copyOf(loggers); }
/** * Adds another logger to this multi-logger. * @param logger The logger to add. */ @API public void addLogger(ILogger logger) { this.loggers.add(logger); }
/** * Creates a multi-logger from the given loggers. Note: These loggers may be MultiLogger-s themselves. * @param loggers The loggers. */ @API public MultiLogger(ILogger... loggers) { this.loggers = Sets.newHashSet(loggers); }
/** * Ads the given logger to this multi-logger. * @param loggers The loggers to add. */ @API public void addLoggers(ILogger... loggers) { this.loggers.addAll(Sets.newHashSet(loggers)); }
/** * Unregisters the object from the event-handlers. * @param listener The object to unregister. */ @API public void unregister(final Object listener) { for (Class clazz = listener.getClass(); clazz != null; clazz = clazz.getSuperclass()) { this.handlersByEventType.removeAll(clazz); } }
/** * Returns a logger with the given name that prints all the messages to standard output. * Guaranteed to create a new logger each time. * @param name The name of the logger. * @return a logger that prints to standard output. */ @API public static ILogger getSysoutLogger(String name) { return new OSLogger(System.out, name); }
/** * Returns a cached logger that prints all the messages to standard error. * @return a logger that prints to standard error. */ @API public static ILogger getSyserrLogger() { if (ERR_LOGGER == null) ERR_LOGGER = new OSLogger(System.err, ""); return ERR_LOGGER; }
/** * @return the throwable to log. May be null. */ @API @Nullable public Throwable getThrowable() { return throwable; } }
/** * Returns a cached logger that will print messages with level {@link LogLevel#INFO INFO} and below to * standard output, and messages with level above {@link LogLevel#INFO INFO} to standard error. * @return A logger that prints to the standard channels. */ @API public static ILogger getStdLogger() { if (STD_LOGGER == null) STD_LOGGER = new OSLogger(System.out, System.err, ""); return STD_LOGGER; }
/** * Returns a logger with the given name that will print messages with level {@link LogLevel#INFO INFO} and below to * standard output, and messages with level above {@link LogLevel#INFO INFO} to standard error. * Guaranteed to create a new logger each time. * @param name The name of the logger. * @return A logger that prints to the standard channels. */ @API public static ILogger getStdLogger(String name) { return new OSLogger(System.out, System.err, name); }
/** * Returns a cached logger that prints all the messages to standard output. * @return a logger that prints to standard output. */ @API public static ILogger getSysoutLogger() { if (OUT_LOGGER == null) OUT_LOGGER = new OSLogger(System.out, ""); return OUT_LOGGER; }
/** * Returns a logger with the given name that prints all the messages to standard error. * Guaranteed to create a new logger each time. * @param name The name of the logger. * @return a logger that prints to standard error. */ @API public static ILogger getSyserrLogger(String name) { return new OSLogger(System.err, name); }
/** * Closes the underlying output stream. */ @API public void close() { this.close(true); }