/** * Get a logger, given a loggable class * @param clazz a Loggable class * @param initHook an init hook - if this is the first time the logger is created in the context, run the init hook * @return debuglogger associated with that class */ public DebugLogger getLogger(final Class<? extends Loggable> clazz, final Consumer<DebugLogger> initHook) { final String name = getLoggerName(clazz); DebugLogger logger = loggers.get(name); if (logger == null) { if (!env.hasLogger(name)) { return DebugLogger.DISABLED_LOGGER; } final LoggerInfo info = env._loggers.get(name); logger = new DebugLogger(name, info.getLevel(), info.isQuiet()); if (initHook != null) { initHook.accept(logger); } loggers.put(name, logger); } return logger; }
private void initLoggers() { ((Loggable)MethodHandleFactory.getFunctionality()).initLogger(this); }
/** * Given a Loggable class, weave debug info info a method handle for that logger. * * @param clazz loggable * @param level log level * @param mh method handle * @param paramStart first parameter to print * @param printReturnValue should we print the return vaulue? * @param text debug printout to add * * @return instrumented method handle, or null if logger not enabled */ public MethodHandle addLoggingToHandle(final Class<? extends Loggable> clazz, final Level level, final MethodHandle mh, final int paramStart, final boolean printReturnValue, final Supplier<String> text) { final DebugLogger log = getLogger(clazz); if (log.isEnabled()) { return MethodHandleFactory.addDebugPrintout(log, level, mh, paramStart, printReturnValue, text.get()); } return mh; }
/** * Given a Loggable class, weave debug info info a method handle for that logger. * * @param clazz loggable * @param level log level * @param mh method handle * @param paramStart first parameter to print * @param printReturnValue should we print the return value? * @param text debug printout to add * * @return instrumented method handle, or null if logger not enabled */ public MethodHandle addLoggingToHandle(final Class<? extends Loggable> clazz, final Level level, final MethodHandle mh, final int paramStart, final boolean printReturnValue, final Supplier<String> text) { final DebugLogger log = getLogger(clazz); if (log.isEnabled()) { return MethodHandleFactory.addDebugPrintout(log, level, mh, paramStart, printReturnValue, text.get()); } return mh; }
/** * Get a logger, given a loggable class * @param clazz a Loggable class * @return debuglogger associated with that class */ public DebugLogger getLogger(final Class<? extends Loggable> clazz) { return getLogger(clazz, null); }
/** * Given a Loggable class, weave debug info info a method handle for that logger. * Level.INFO is used * * @param clazz loggable * @param mh method handle * @param text debug printout to add * * @return instrumented method handle, or null if logger not enabled */ public MethodHandle addLoggingToHandle(final Class<? extends Loggable> clazz, final MethodHandle mh, final Supplier<String> text) { return addLoggingToHandle(clazz, Level.INFO, mh, Integer.MAX_VALUE, false, text); }