@Override public void flush() throws IOException { if (baos.size() > 0) { LogRecord lr = new LogRecord(level, baos.toString()); lr.setLoggerName(logger.getName()); lr.setSourceClassName(caller.getClassName()); lr.setSourceMethodName(caller.getMethodName()); logger.log(lr); } baos.reset(); }
public void publish(Logger source, String tag, Level level, String message) { LogRecord record = new LogRecord(level, message); record.setLoggerName(source.name); source.setResourceBundle(record); source.log(record); } };
private void log(java.util.logging.Level level, Object message, Throwable exception) { if (this.logger.isLoggable(level)) { LogRecord rec; if (message instanceof LogRecord) { rec = (LogRecord) message; } else { rec = new LocationResolvingLogRecord(level, String.valueOf(message)); rec.setLoggerName(this.name); rec.setResourceBundleName(logger.getResourceBundleName()); rec.setResourceBundle(logger.getResourceBundle()); rec.setThrown(exception); } logger.log(rec); } }
/** * Logs a warning. This method is invoked automatically by the {@link #parse parse} method when * a text can't be fully parsed. The default implementation logs the warning to the logger * specified by the last call to the {@link #setLogger setLogger} method. Subclasses may * override this method if they want to change the log record before the logging. * * @param warning The warning to log. */ protected void logWarning(final LogRecord warning) { if (logger != null) { final Logger logger = Logging.getLogger(this.logger); warning.setLoggerName(logger.getName()); logger.log(warning); } }
public static LogRecord logRecordFromJson(String jsonString) throws InvalidJsonLogRecordFormatException { try { JSONObject lro = new JSONObject(jsonString); String level = lro.getString("level"); String loggerName = lro.getString("loggerName"); String msg = lro.getString("msg"); long timestamp = Long.parseLong(lro.getString("timestamp")); Throwable thrown = JsonLogRecordThrowable.fromJsonString(lro.getString("thrown")); LogRecord lr = new LogRecord(Level.parse(level), msg); lr.setLoggerName(loggerName); lr.setThrown(thrown); lr.setMillis(timestamp); return lr; } catch (JSONException e) { throw new InvalidJsonLogRecordFormatException(e); } }
private void log(Level level, Object message, Throwable t, Object... params) { if (!logger.isLoggable(level)) { return; } String msg = (message == null) ? "NULL" : message.toString(); LogRecord record = new LogRecord(level, msg); record.setLoggerName(logger.getName()); if (t != null) { record.setThrown(t); } else if (params != null && params.length != 0 && params[params.length - 1] instanceof Throwable) { // The exception may be the last parameters (SLF4J uses this convention). record.setThrown((Throwable) params[params.length - 1]); } // This will disable stack trace lookup inside JUL. If someone wants location info, they can use their own formatter // or use a different logging framework like sl4j, or log4j record.setSourceClassName(null); record.setParameters(params); logger.log(record); }
record.setLoggerName(LOGGER.getName()); LOGGER.log(record);
/** * Logs a message of the specified level with the supplied parameter array. * The message is then transmitted to all subscribed handlers. * * @param logLevel * the level of the given message * @param msg * the message to log. * @param params * the parameter array associated with the event that is logged. */ public void log(Level logLevel, String msg, Object[] params) { if (!internalIsLoggable(logLevel)) { return; } LogRecord record = new LogRecord(logLevel, msg); record.setLoggerName(this.name); record.setParameters(params); setResourceBundle(record); log(record); }
/** * Log the message at the specified level with the specified throwable if any. * This method creates a LogRecord and fills in caller date before calling * this instance's JDK14 logger. * * See bug report #13 for more details. */ private void log(String callerFQCN, Level level, String msg, Throwable t) { // millis and thread are filled by the constructor LogRecord record = new LogRecord(level, msg); record.setLoggerName(name()); record.setThrown(t); fillCallerData(callerFQCN, record); logger.log(record); }
final LogRecord record = Loggings.format(Level.FINE, LoggingKeys.LOADING_DATUM_ALIASES_$1, aliasURL); record.setLoggerName(LOGGER.getName()); LOGGER.log(record); final BufferedReader in = new BufferedReader(new InputStreamReader(aliasURL.openStream()));
/** * Logs a message of the specified level with the supplied parameter. The * message is then transmitted to all subscribed handlers. * * @param logLevel * the level of the given message. * @param msg * the message to log. * @param param * the parameter associated with the event that is logged. */ public void log(Level logLevel, String msg, Object param) { if (!internalIsLoggable(logLevel)) { return; } LogRecord record = new LogRecord(logLevel, msg); record.setLoggerName(this.name); record.setParameters(new Object[] { param }); setResourceBundle(record); log(record); }
private static void log(Level level, String msg, Throwable thrown, Object... params) { if (!LOGGER.isLoggable(level)) { return; } LogRecord rec = new LogRecord(level, msg); // Set the loggerName of the LogRecord with the current logger rec.setLoggerName(LOGGER.getName()); rec.setParameters(params); rec.setThrown(thrown); LOGGER.log(rec); }
record.setLoggerName(LOGGER.getName()); LOGGER.log(record);
/** * Log the message at the specified level with the specified throwable if any. * This method creates a LogRecord and fills in caller date before calling * this instance's JDK14 logger. * * See bug report #13 for more details. */ private void log(String callerFQCN, Level level, String msg, Throwable t) { // millis and thread are filled by the constructor LogRecord record = new LogRecord(level, msg); record.setLoggerName(name()); record.setThrown(t); fillCallerData(callerFQCN, record); logger.log(record); }
logger.log(Level.FINE, "Building backing store for " + getClass().getName()); LoggingKeys.CREATING_CACHED_EPSG_DATABASE_$1, VERSION); record.setLoggerName(logger.getName()); logger.log(record);
private void log(Level level, Object message, Throwable t, Object... params) { if (!logger.isLoggable(level)) { return; } String msg = (message == null) ? "NULL" : message.toString(); LogRecord record = new LogRecord(level, msg); record.setLoggerName(logger.getName()); if (t != null) { record.setThrown(t); } else if (params != null && params.length != 0 && params[params.length - 1] instanceof Throwable) { // The exception may be the last parameters (SLF4J uses this convention). record.setThrown((Throwable) params[params.length - 1]); } // This will disable stack trace lookup inside JUL. If someone wants location info, they can use their own // formatter // or use a different logging framework like sl4j, or log4j record.setSourceClassName(null); record.setParameters(params); logger.log(record); }
/** * Creates the backing store authority factory. * * @return The backing store to uses in {@code createXXX(...)} methods. * @throws FactoryNotFoundException if the no {@code epsg.properties} file has been found. * @throws FactoryException if the constructor failed to find or read the file. This exception * usually has an {@link IOException} as its cause. */ protected AbstractAuthorityFactory createBackingStore() throws FactoryException { try { URL url = getDefinitionsURL(); if (url == null) { throw new FactoryNotFoundException( Errors.format(ErrorKeys.FILE_DOES_NOT_EXIST_$1, FILENAME)); } final Iterator<? extends Identifier> ids = getAuthority().getIdentifiers().iterator(); final String authority = ids.hasNext() ? ids.next().getCode() : "EPSG"; final LogRecord record = Loggings.format( Level.CONFIG, LoggingKeys.USING_FILE_AS_FACTORY_$2, url.getPath(), authority); record.setLoggerName(LOGGER.getName()); LOGGER.log(record); return new PropertyAuthorityFactory(factories, getAuthorities(), url); } catch (IOException exception) { throw new FactoryException(Errors.format(ErrorKeys.CANT_READ_$1, FILENAME), exception); } }
/** * Log the message at the specified level with the specified throwable if any. * This method creates a LogRecord and fills in caller date before calling * this instance's JDK14 logger. * * See bug report #13 for more details. */ private void log(String callerFQCN, Level level, String msg, Throwable t) { // millis and thread are filled by the constructor LogRecord record = new LogRecord(level, msg); record.setLoggerName(name()); record.setThrown(t); fillCallerData(callerFQCN, record); logger.log(record); }
url.getPath(), authority); record.setLoggerName(LOGGER.getName()); LOGGER.log(record); return new PropertyCoordinateOperationAuthorityFactory( factories, this.getAuthority(), url);
/** * Logs a message indicating that a method has been entered. A log record * with log level {@code Level.FINER}, log message "ENTRY", the specified * source class name and source method name is submitted for logging. * * @param sourceClass * the calling class name. * @param sourceMethod * the method name. */ public void entering(String sourceClass, String sourceMethod) { if (!internalIsLoggable(Level.FINER)) { return; } LogRecord record = new LogRecord(Level.FINER, "ENTRY"); record.setLoggerName(this.name); record.setSourceClassName(sourceClass); record.setSourceMethodName(sourceMethod); setResourceBundle(record); log(record); }