TinylogLoggerProvider implements LoggerProvider { @Override public Logger getLogger(final String name) { TinylogLogger logger = loggers.get(name); if (logger == null) { TinylogLogger newLogger = new TinylogLogger(name); TinylogLogger existingLogger = loggers.putIfAbsent(name, newLogger); return existingLogger == null ? newLogger : existingLogger; } else { return logger; } } TinylogLoggerProvider(); @Override Logger getLogger(final String name); @Override void clearMdc(); @Override Object putMdc(final String key, final Object value); @Override Object getMdc(final String key); @Override void removeMdc(final String key); @SuppressWarnings({ "unchecked", "rawtypes" }) @Override Map<String, Object> getMdcMap(); @Override void clearNdc(); @Override String getNdc(); @Override int getNdcDepth(); @Override String popNdc(); @Override String peekNdc(); @Override void pushNdc(final String message); @Override void setNdcMaxDepth(final int maxDepth);  }
@Test public void newLoggerInstance() { assertThat(logging.getLogger("org.test.MyClass")).isInstanceOf(TinylogLogger.class); }
@Test public void cachedLoggerInstance() { Logger first = logging.getLogger("org.test.MyClass"); Logger second = logging.getLogger("org.test.MyClass"); assertThat(first).isSameAs(second); }
@Test public void differentLoggerInstance() { Logger first = logging.getLogger("org.test.FirstClass"); Logger second = logging.getLogger("org.test.SecondClass"); assertThat(first).isNotSameAs(second); }