TinylogLoggerFactory implements ILoggerFactory { @Override public TinylogLogger 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; } } TinylogLoggerFactory(); @Override TinylogLogger getLogger(final String name);  }
@Test public void sameLoggers() { TinylogLoggerFactory factory = new TinylogLoggerFactory(); TinylogLogger first = factory.getLogger("abc"); assertThat(first.getName()).isEqualTo("abc"); TinylogLogger second = factory.getLogger("abc"); assertThat(second.getName()).isEqualTo("abc"); assertThat(second).isSameAs(first); }
@Test public void differentLoggers() { TinylogLoggerFactory factory = new TinylogLoggerFactory(); TinylogLogger first = factory.getLogger("abc"); assertThat(first.getName()).isEqualTo("abc"); TinylogLogger second = factory.getLogger("ABC"); assertThat(second.getName()).isEqualTo("ABC"); }