Search in sources :

Example 1 with Logger

use of org.osgl.logging.Logger in project actframework by actframework.

the class SimpleMetricPlugin method metric.

@Override
public Metric metric(String name) {
    if (!Act.appConfig().metricEnabled()) {
        return Metric.NULL_METRIC;
    }
    Logger logger = enabledMap.get(name);
    if (null == logger) {
        logger = LogManager.get("metric." + name);
        enabledMap.put(name, logger);
    }
    return logger.isTraceEnabled() ? metric() : Metric.NULL_METRIC;
}
Also used : Logger(org.osgl.logging.Logger)

Example 2 with Logger

use of org.osgl.logging.Logger in project actframework by actframework.

the class LogAdmin method setLogLevel.

@Command(name = "act.log.level.update", help = "Update LOGGER level. Valid levels are:\n\t" + "5 - fatal\n\t" + "4 - error\n\t" + "3 - warn\n\t" + "2 - info\n\t" + "1 - debug\n\t" + "0 - trace")
public String setLogLevel(@Required("specify LOGGER name") String name, @Required("specify log level") int level) {
    Level lvl = convert(level);
    Logger logger = LogManager.get(name);
    logger.setLevel(lvl);
    return S.fmt("LOGGER[%s] level set to %s", name, lvl.toString());
}
Also used : Level(org.osgl.logging.Logger.Level) Logger(org.osgl.logging.Logger) Command(act.cli.Command)

Example 3 with Logger

use of org.osgl.logging.Logger in project actframework by actframework.

the class App method configureLoggingLevels.

private void configureLoggingLevels(AppConfig config) {
    Map map = config.subSet("log.level");
    map.putAll(config.subSet("act.log.level"));
    for (Object o : map.entrySet()) {
        Map.Entry<String, String> entry = $.cast(o);
        String key = entry.getKey();
        if (key.startsWith("log.level")) {
            key = key.substring("log.level.".length());
        } else {
            key = key.substring("act.log.level.".length());
        }
        Logger.Level level = loggerLevelOf(entry.getValue());
        E.invalidConfigurationIf(null == level, "Unknown log level: %s", entry.getValue());
        Logger logger = LogManager.get(key);
        logger.setLevel(level);
    }
}
Also used : Logger(org.osgl.logging.Logger)

Aggregations

Logger (org.osgl.logging.Logger)3 Command (act.cli.Command)1 Level (org.osgl.logging.Logger.Level)1