org.slf4j.helpers.NOPLoggerFactory#org.slf4j.helpers.Util源码实例Demo

下面列出了org.slf4j.helpers.NOPLoggerFactory#org.slf4j.helpers.Util 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: HttpSessionReplacer   文件: SimpleLogger.java
private static PrintStream computeTargetStream(String logFile) {
  if ("System.err".equalsIgnoreCase(logFile))
    return System.err; // NOSONAR
  else if ("System.out".equalsIgnoreCase(logFile)) {
    return System.out; // NOSONAR
  } else {
    try {
      FileOutputStream fos = new FileOutputStream(logFile);
      PrintStream printStream = new PrintStream(fos);
      return printStream;
    } catch (FileNotFoundException e) {
      Util.report("Could not open [" + logFile + "]. Defaulting to System.err", e);
      return System.err; // NOSONAR
    }
  }
}
 
void init() {
    try {
        try {
            (new KonkerContextInitializer(this.defaultLoggerContext)).autoConfig();
        } catch (JoranException var2) {
            Util.report("Failed to auto configure default logger context", var2);
        }

        if(!StatusUtil.contextHasStatusListener(this.defaultLoggerContext)) {
            StatusPrinter.printInCaseOfErrorsOrWarnings(this.defaultLoggerContext);
        }

        this.contextSelectorBinder.init(this.defaultLoggerContext, KEY);
        this.initialized = true;
    } catch (Throwable var3) {
        Util.report("Failed to instantiate [" + LoggerContext.class.getName() + ']', var3);
    }

}
 
源代码3 项目: konker-platform   文件: KonkerLoggerFactory.java
private static final void fixSubstitutedLoggers() {
    List loggers = TEMP_FACTORY.getLoggers();
    if(!loggers.isEmpty()) {
        Util.report("The following set of substitute loggers may have been accessed");
        Util.report("during the initialization phase. Logging calls during this");
        Util.report("phase were not honored. However, subsequent logging calls to these");
        Util.report("loggers will work as normally expected.");
        Util.report("See also http://www.slf4j.org/codes.html#substituteLogger");
        Iterator i$ = loggers.iterator();

        while(i$.hasNext()) {
            SubstituteLogger subLogger = (SubstituteLogger)i$.next();
            subLogger.setDelegate(getKonkerLogger(subLogger.getName()));
            Util.report(subLogger.getName());
        }

        TEMP_FACTORY.clear();
    }
}
 
源代码4 项目: konker-platform   文件: KonkerLoggerFactory.java
private static final void versionSanityCheck() {
    try {
        String e = StaticLoggerBinder.REQUESTED_API_VERSION;
        boolean match = false;
        String[] arr$ = API_COMPATIBILITY_LIST;
        int len$ = arr$.length;

        for(int i$ = 0; i$ < len$; ++i$) {
            String aAPI_COMPATIBILITY_LIST = arr$[i$];
            if(e.startsWith(aAPI_COMPATIBILITY_LIST)) {
                match = true;
            }
        }

        if(!match) {
            Util.report("The requested version " + e + " by your slf4j binding is not compatible with " + Arrays.asList(API_COMPATIBILITY_LIST));
            Util.report("See http://www.slf4j.org/codes.html#version_mismatch for further details.");
        }
    } catch (NoSuchFieldError var6) {
    } catch (Throwable var7) {
        Util.report("Unexpected problem occured during version sanity check", var7);
    }

}
 
源代码5 项目: konker-platform   文件: KonkerLoggerFactory.java
static Set<URL> findPossibleStaticLoggerBinderPathSet() {
    LinkedHashSet staticLoggerBinderPathSet = new LinkedHashSet();

    try {
        ClassLoader ioe = LoggerFactory.class.getClassLoader();
        Enumeration paths;
        if(ioe == null) {
            paths = ClassLoader.getSystemResources(STATIC_LOGGER_BINDER_PATH);
        } else {
            paths = ioe.getResources(STATIC_LOGGER_BINDER_PATH);
        }

        while(paths.hasMoreElements()) {
            URL path = (URL)paths.nextElement();
            staticLoggerBinderPathSet.add(path);
        }
    } catch (IOException var4) {
        Util.report("Error getting resources from path", var4);
    }

    return staticLoggerBinderPathSet;
}
 
源代码6 项目: konker-platform   文件: KonkerLoggerFactory.java
private static void reportMultipleBindingAmbiguity(Set<URL> staticLoggerBinderPathSet) {
    if(!isAndroid()) {
        if(isAmbiguousStaticLoggerBinderPathSet(staticLoggerBinderPathSet)) {
            Util.report("Class path contains multiple SLF4J bindings.");
            Iterator i$ = staticLoggerBinderPathSet.iterator();

            while(i$.hasNext()) {
                URL path = (URL)i$.next();
                Util.report("Found binding in [" + path + ']');
            }

            Util.report("See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.");
        }

    }
}
 
源代码7 项目: JDA   文件: SimpleLogger.java
private static PrintStream computeTargetStream(String logFile) {
    if ("System.err".equalsIgnoreCase(logFile))
        return System.err;
    else if ("System.out".equalsIgnoreCase(logFile)) {
        return System.out;
    } else {
        try {
            FileOutputStream fos = new FileOutputStream(logFile);
            PrintStream printStream = new PrintStream(fos);
            return printStream;
        } catch (FileNotFoundException e) {
            Util.report("Could not open [" + logFile + "]. Defaulting to System.err", e);
            return System.err;
        }
    }
}
 
/**
 * Instantiates a new Cas logger factory.
 * Configures the reflection scanning engine to be prepared to scan <code>org.slf4j.impl</code>
 * in order to find other available factories.
 */
public CasLoggerFactory() {
    this.loggerMap = new ConcurrentHashMap<>();
    final Collection<URL> set = ClasspathHelper.forPackage(PACKAGE_TO_SCAN);
    final Reflections reflections = new Reflections(new ConfigurationBuilder().addUrls(set).setScanners(new SubTypesScanner()));

    final Set<Class<? extends ILoggerFactory>> subTypesOf = reflections.getSubTypesOf(ILoggerFactory.class);
    subTypesOf.remove(this.getClass());

    if (subTypesOf.size() > 1) {
        Util.report("Multiple ILoggerFactory bindings are found on the classpath:");
        for (final Class<? extends ILoggerFactory> c : subTypesOf) {
            Util.report("* " + c.getCanonicalName());
        }
    }

    if (subTypesOf.isEmpty()) {
        final RuntimeException e = new RuntimeException("No ILoggerFactory could be found on the classpath."
                + " CAS cannot determine the logging framework."
                + " Examine the project dependencies and ensure that there is one and only one logging framework available.");

        Util.report(e.getMessage(), e);
        throw e;
    }
    this.realLoggerFactoryClass = subTypesOf.iterator().next();
    Util.report("ILoggerFactory to be used for logging is: " + this.realLoggerFactoryClass.getName());
}
 
@BeforeClass
public static void beforeClass() throws IOException {
    if (LOG_FILE.exists()) {
        Util.report("Initializing log file " + LOG_FILE.getCanonicalPath());
        FileUtils.write(LOG_FILE, "", false);
    }
}
 
源代码10 项目: HttpSessionReplacer   文件: SimpleLogger.java
static synchronized void init() {
  INITIALIZED = true;
  loadProperties();

  String defaultLogLevelString = getStringProperty(DEFAULT_LOG_LEVEL_KEY, null);
  if (defaultLogLevelString != null)
    DEFAULT_LOG_LEVEL = stringToLevel(defaultLogLevelString);

  SHOW_LOG_NAME = getBooleanProperty(SHOW_LOG_NAME_KEY, SHOW_LOG_NAME);
  SHOW_SHORT_LOG_NAME = getBooleanProperty(SHOW_SHORT_LOG_NAME_KEY, SHOW_SHORT_LOG_NAME);
  SHOW_DATE_TIME = getBooleanProperty(SHOW_DATE_TIME_KEY, SHOW_DATE_TIME);
  SHOW_THREAD_NAME = getBooleanProperty(SHOW_THREAD_NAME_KEY, SHOW_THREAD_NAME);
  DATE_TIME_FORMAT_STR = getStringProperty(DATE_TIME_FORMAT_KEY, DATE_TIME_FORMAT_STR);
  LEVEL_IN_BRACKETS = getBooleanProperty(LEVEL_IN_BRACKETS_KEY, LEVEL_IN_BRACKETS);
  WARN_LEVEL_STRING = getStringProperty(WARN_LEVEL_STRING_KEY, WARN_LEVEL_STRING);

  LOG_FILE = getStringProperty(LOG_FILE_KEY, LOG_FILE);
  TARGET_STREAM = computeTargetStream(LOG_FILE);

  if (DATE_TIME_FORMAT_STR != null) {
    try {
      DATE_FORMATTER = new SimpleDateFormat(DATE_TIME_FORMAT_STR);
    } catch (IllegalArgumentException e) {
      Util.report("Bad date format in " + CONFIGURATION_FILE + "; will output relative time", e);
    }
  }
}
 
源代码11 项目: konker-platform   文件: KonkerLoggerFactory.java
private static final void bind() {
    String msg;
    try {
        Set e = findPossibleStaticLoggerBinderPathSet();
        reportMultipleBindingAmbiguity(e);
        StaticLoggerBinder.getSingleton();
        INITIALIZATION_STATE = 3;
        reportActualBinding(e);
        fixSubstitutedLoggers();
    } catch (NoClassDefFoundError var2) {
        msg = var2.getMessage();
        if(!messageContainsOrgSlf4jImplStaticLoggerBinder(msg)) {
            failedBinding(var2);
            throw var2;
        }

        INITIALIZATION_STATE = 4;
        Util.report("Failed to load class \"org.slf4j.impl.StaticLoggerBinder\".");
        Util.report("Defaulting to no-operation (NOP) logger implementation");
        Util.report("See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.");
    } catch (NoSuchMethodError var3) {
        msg = var3.getMessage();
        if(msg != null && msg.contains("org.slf4j.impl.StaticLoggerBinder.getSingleton()")) {
            INITIALIZATION_STATE = 2;
            Util.report("slf4j-api 1.6.x (or later) is incompatible with this binding.");
            Util.report("Your binding is version 1.5.5 or earlier.");
            Util.report("Upgrade your binding to version 1.6.x.");
        }

        throw var3;
    } catch (Exception var4) {
        failedBinding(var4);
        throw new IllegalStateException("Unexpected initialization failure", var4);
    }

}
 
源代码12 项目: konker-platform   文件: KonkerLoggerFactory.java
public static KonkerLogger getLogger(Class<?> clazz) {
    KonkerLogger logger = getKonkerLogger(clazz.getName());
    if(DETECT_LOGGER_NAME_MISMATCH) {
        Class autoComputedCallingClass = Util.getCallingClass();
        if(autoComputedCallingClass != null && nonMatchingClasses(clazz, autoComputedCallingClass)) {
            Util.report(String.format("Detected logger name mismatch. Given name: \"%s\"; computed name: \"%s\".", new Object[]{logger.getName(), autoComputedCallingClass.getName()}));
            Util.report("See http://www.slf4j.org/codes.html#loggerNameMismatch for an explanation");
        }
    }

    return logger;
}
 
源代码13 项目: mdw   文件: LoggerUtil.java
public static StandardLogger getStandardLogger() {
    String loggerImplClass = System.getProperty(MDW_LOGGER_IMPL);
    if (!accessed && loggerImplClass != null) {
        System.out.println("\nUsing Logger Impl: " + loggerImplClass);
        accessed = true;
    }
    Class<?> callingClass = Util.getCallingClass();
    StandardLogger logger;
    // avoid reflection for known impls
    if (loggerImplClass == null) {
        logger = new Slf4JStandardLoggerImpl(callingClass.getName());
    }
    else if (SimpleLogger.class.getName().equals(loggerImplClass)) {
        logger = SimpleLogger.getSingleton();
    }
    else if (Log4JStandardLoggerImpl.class.getName().equals(loggerImplClass) || org.apache.log4j.Logger.class.getName().equals(loggerImplClass)) {
        logger = new Log4JStandardLoggerImpl();
    }
    else if (Slf4JStandardLoggerImpl.class.getName().equals(loggerImplClass) || org.slf4j.Logger.class.getName().equals(loggerImplClass)) {
        logger = new Slf4JStandardLoggerImpl(callingClass.getName());
    }
    else {
        try {
            logger = Class.forName(loggerImplClass).asSubclass(StandardLogger.class).newInstance();
        }
        catch (Exception ex) {
            ex.printStackTrace();  // logging isn't working
            return null;
        }
    }
    checkWarnActivityLogging(logger, callingClass);
    return logger;
}
 
源代码14 项目: JDA   文件: SimpleLogger.java
static void init() {
    INITIALIZED = true;
    loadProperties();

    String defaultLogLevelString = getStringProperty(DEFAULT_LOG_LEVEL_KEY, null);
    if (defaultLogLevelString != null)
        DEFAULT_LOG_LEVEL = stringToLevel(defaultLogLevelString);

    SHOW_LOG_NAME = getBooleanProperty(SHOW_LOG_NAME_KEY, SHOW_LOG_NAME);
    SHOW_SHORT_LOG_NAME = getBooleanProperty(SHOW_SHORT_LOG_NAME_KEY, SHOW_SHORT_LOG_NAME);
    SHOW_DATE_TIME = getBooleanProperty(SHOW_DATE_TIME_KEY, SHOW_DATE_TIME);
    SHOW_THREAD_NAME = getBooleanProperty(SHOW_THREAD_NAME_KEY, SHOW_THREAD_NAME);
    DATE_TIME_FORMAT_STR = getStringProperty(DATE_TIME_FORMAT_KEY, DATE_TIME_FORMAT_STR);
    LEVEL_IN_BRACKETS = getBooleanProperty(LEVEL_IN_BRACKETS_KEY, LEVEL_IN_BRACKETS);
    WARN_LEVEL_STRING = getStringProperty(WARN_LEVEL_STRING_KEY, WARN_LEVEL_STRING);

    LOG_FILE = getStringProperty(LOG_FILE_KEY, LOG_FILE);
    TARGET_STREAM = computeTargetStream(LOG_FILE);

    if (DATE_TIME_FORMAT_STR != null) {
        try {
            DATE_FORMATTER = new SimpleDateFormat(DATE_TIME_FORMAT_STR);
        } catch (IllegalArgumentException e) {
            Util.report("Bad date format in " + CONFIGURATION_FILE + "; will output relative time", e);
        }
    }
}
 
源代码15 项目: konker-platform   文件: KonkerLoggerFactory.java
static void failedBinding(Throwable t) {
    INITIALIZATION_STATE = 2;
    Util.report("Failed to instantiate SLF4J LoggerFactory", t);
}
 
源代码16 项目: konker-platform   文件: KonkerLoggerFactory.java
private static boolean isAndroid() {
    String vendor = Util.safeGetSystemProperty("java.vendor.url");
    return vendor == null?false:vendor.toLowerCase().contains("android");
}
 
源代码17 项目: konker-platform   文件: KonkerLoggerFactory.java
private static void reportActualBinding(Set<URL> staticLoggerBinderPathSet) {
    if(isAmbiguousStaticLoggerBinderPathSet(staticLoggerBinderPathSet)) {
        Util.report("Actual binding is of type [" + StaticLoggerBinder.getSingleton().getLoggerFactoryClassStr() + ']');
    }

}