org.slf4j.impl.SimpleLogger Java Examples
The following examples show how to use
org.slf4j.impl.SimpleLogger.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoggerMocking.java From development with Apache License 2.0 | 6 votes |
/** * Adds a little (not complete) console debug output to a mocked logger. * * @param mogger * the mocked logger */ public static void addConsoleDebug(SimpleLogger mogger) { Answer<Void> answer = new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { Object[] arguments = invocation.getArguments(); if (arguments != null && arguments.length > 0 && arguments[0] != null) { System.out.println(arguments[0]); } return null; } }; Mockito.doAnswer(answer).when(mogger).debug(Matchers.anyString()); Mockito.doAnswer(answer).when(mogger).debug(Matchers.anyString(), Matchers.any(Throwable.class)); }
Example #2
Source File: GeoFireTestingRule.java From geofire-java with MIT License | 6 votes |
@Override public void starting(Description description) { if (FirebaseApp.getApps().isEmpty()) { final GoogleCredentials credentials; try { credentials = GoogleCredentials.fromStream(new FileInputStream(SERVICE_ACCOUNT_CREDENTIALS)); } catch (IOException e) { throw new RuntimeException(e); } FirebaseOptions firebaseOptions = new FirebaseOptions.Builder() .setDatabaseUrl(databaseUrl) .setCredentials(credentials) .build(); FirebaseApp.initializeApp(firebaseOptions); System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "DEBUG"); } this.databaseReference = FirebaseDatabase.getInstance().getReferenceFromUrl(databaseUrl); }
Example #3
Source File: TestGetJMSQueue.java From localization_nifi with Apache License 2.0 | 5 votes |
private ByteArrayOutputStream prepLogOutputStream() throws Exception { LoggerFactory.getLogger(GetJMSQueue.class); Field field = SimpleLogger.class.getDeclaredField("TARGET_STREAM"); field.setAccessible(true); ByteArrayOutputStream bos = new ByteArrayOutputStream(); field.set(null, new PrintStream(bos)); return bos; }
Example #4
Source File: Main.java From DocBleach with MIT License | 5 votes |
private void setupLogging() { if (verbosityLevel <= 0) { // Verbosity is INFO or OFF, we hide the thread and logger names System.setProperty(SimpleLogger.SHOW_THREAD_NAME_KEY, "false"); System.setProperty(SimpleLogger.SHOW_LOG_NAME_KEY, "false"); } String level; switch (verbosityLevel) { case -1: level = "OFF"; break; case 1: level = "DEBUG"; break; case 2: level = "TRACE"; break; default: level = "INFO"; break; } System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, level); LOGGER = LoggerFactory.getLogger(Main.class); LOGGER.debug("Log Level: {}", level); }
Example #5
Source File: AbstractUpdateImportsTest.java From flow with Apache License 2.0 | 5 votes |
@Before public void setup() throws Exception { tmpRoot = temporaryFolder.getRoot(); // Use a file for logs so as tests can assert the warnings shown to the // user. loggerFile = new File(tmpRoot, "test.log"); loggerFile.createNewFile(); // Setting a system property we make SimpleLogger to output to a file System.setProperty(SimpleLogger.LOG_FILE_KEY, loggerFile.getAbsolutePath()); // re-init logger to get new configuration initLogger(); frontendDirectory = new File(tmpRoot, DEFAULT_FRONTEND_DIR); nodeModulesPath = new File(tmpRoot, NODE_MODULES); generatedPath = new File(tmpRoot, DEFAULT_GENERATED_DIR); File tokenFile = new File(tmpRoot, TOKEN_FILE); ClassFinder classFinder = getClassFinder(); updater = new UpdateImports(classFinder, getScanner(classFinder), tmpRoot, tokenFile); assertTrue(nodeModulesPath.mkdirs()); createExpectedImports(frontendDirectory, nodeModulesPath); assertTrue(new File(nodeModulesPath, FLOW_NPM_PACKAGE_NAME + "ExampleConnector.js").exists()); }
Example #6
Source File: AbstractNodeUpdateImportsTest.java From flow with Apache License 2.0 | 5 votes |
@Before public void setup() throws Exception { File tmpRoot = temporaryFolder.getRoot(); // Use a file for logs so as tests can assert the warnings shown to the // user. loggerFile = new File(tmpRoot, "test.log"); loggerFile.createNewFile(); // Setting a system property we make SimpleLogger to output to a file System.setProperty(SimpleLogger.LOG_FILE_KEY, loggerFile.getAbsolutePath()); // re-init logger to get new configuration initLogger(); frontendDirectory = new File(tmpRoot, DEFAULT_FRONTEND_DIR); nodeModulesPath = new File(tmpRoot, NODE_MODULES); generatedPath = new File(tmpRoot, DEFAULT_GENERATED_DIR); importsFile = new File(generatedPath, IMPORTS_NAME); ClassFinder classFinder = getClassFinder(); updater = new TaskUpdateImports(classFinder, getScanner(classFinder), finder -> null, tmpRoot, generatedPath, frontendDirectory, null, null, false) { @Override Logger log() { if (useMockLog) { return logger; } else { return super.log(); } } }; assertTrue(nodeModulesPath.mkdirs()); createExpectedImports(frontendDirectory, nodeModulesPath); assertTrue(new File(nodeModulesPath, FLOW_NPM_PACKAGE_NAME + "ExampleConnector.js").exists()); }
Example #7
Source File: Main.java From pomutils with Apache License 2.0 | 5 votes |
protected static int mainInternal(String... args) { CommandMain mainCommand = new CommandMain(); CommandPomMergeDriver mergeCommand = new CommandPomMergeDriver(); CommandPomVersionReplacer versionReplacerCommand = new CommandPomVersionReplacer(); JCommander jc = new JCommander(mainCommand); jc.addCommand("merge", mergeCommand); jc.addCommand("replace", versionReplacerCommand); try { jc.parse(args); } catch (ParameterException e) { System.err.println(e.getMessage()); return 1; } String logLevel = mainCommand.isDebug() ? "debug" : "error"; System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, logLevel); logger = LoggerFactory.getLogger(Main.class); if (logger.isInfoEnabled()) { logger.info("PomUtils version {}", ManifestUtils.getImplementationVersion()); } if ("merge".equals(jc.getParsedCommand())) { return executePomMergeDriver(mergeCommand); } else if ("replace".equals(jc.getParsedCommand())) { executePomVersionReplacer(versionReplacerCommand); return 0; } jc.usage(); return 1; }
Example #8
Source File: CacheClientTest.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@Before public void before() { System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "TRACE"); }
Example #9
Source File: AbstractUpdateImportsTest.java From flow with Apache License 2.0 | 4 votes |
@After public void tearDown() throws Exception { // re-init logger to reset to default System.clearProperty(SimpleLogger.LOG_FILE_KEY); initLogger(); }
Example #10
Source File: AbstractUpdateImportsTest.java From flow with Apache License 2.0 | 4 votes |
private void initLogger() throws Exception, SecurityException { // init method is protected Method method = SimpleLogger.class.getDeclaredMethod("init"); method.setAccessible(true); method.invoke(null); }
Example #11
Source File: AbstractNodeUpdateImportsTest.java From flow with Apache License 2.0 | 4 votes |
@After public void tearDown() throws Exception { // re-init logger to reset to default System.clearProperty(SimpleLogger.LOG_FILE_KEY); initLogger(); }
Example #12
Source File: AbstractNodeUpdateImportsTest.java From flow with Apache License 2.0 | 4 votes |
private void initLogger() throws Exception, SecurityException { // init method is protected Method method = SimpleLogger.class.getDeclaredMethod("init"); method.setAccessible(true); method.invoke(null); }