Repository navigation
v1.2
Nanolog 1.2 makes the library easier to use and to debug in agent-driven development, where a coding agent edits, runs and reads the output in a short loop. The public API only grows, and every change below is covered by tests under a 100% pitest mutation threshold.
New
- SLF4J argument order. A trailing
Throwablethat no{}placeholder consumes becomes the exception of the entry, soLOG.error("Failed", e)andLOG.error("Failed {}", id, e)log the stack trace. Before, the exception was silently dropped as an unused argument. - Call site.
LogEntry.getCaller()returns the frame of the logging call, andConsoleLogger.setShowLocation(true)prints it as[PaymentService.charge(PaymentService.java:87)], a link in IDEs and terminals. It comes from the stack walk that already detects the source class, so it costs nothing extra. - Levels and options without code.
ConsoleLoggerreadsnanolog.level, per-package or per-class rules (nanolog.level.com.acme.payments=DEBUG,nanolog.levels) and thenanolog.console.*display options. A package rule beats the global level, even one set in code. - Environment variables. Every setting,
nanolog.loggerandnanolog.configincluded, can be set as an environment variable (NANOLOG_LEVEL,NANOLOG_LOGGER). Precedence:-D, environment,nanolog.properties. JsonLogger. One JSON object per line withts,level,logger,thread,message,template,args,callerandexception, selectable with-Dnanolog.logger=com.nanolaba.logging.JsonLogger.LogEntry.getTimestamp()andLogEntry.getThreadName()record when and where an entry was created.MemoryLoggerandCompositeLogger.try (MemoryLogger log = MemoryLogger.install()) { ... }captures entries in a test and puts the previous logger back afterwards;CompositeLoggersends entries to several loggers.nanolog.strict=true. Reports calls whose{}placeholders and arguments do not match, once per template and with the call site. Meant for test runs.
Fixes
Slf4jLogger: Logback, Log4j 2 and other location-aware backends report the code that calledLOGin%file:%lineand%l, instead ofSlf4jLogger.log.ConsoleLogger: a throwable whosetoString()throws no longer escapes from the logging call; it is printed as[FAILED printStackTrace()].
Documentation and build
- Javadoc for the whole public API; the build fails on a missing comment.
llms.txtand the agent skillskills/nanolog/SKILL.mdgive coding agents the rules of the library. Both are generated together with the README and checked for drift in CI.- README: a new section on agent-driven development, in English and Russian.
Installation
<dependency>
<groupId>com.nanolaba</groupId>
<artifactId>nanolog</artifactId>
<version>1.2</version>
</dependency>implementation("com.nanolaba:nanolog:1.2")Requires Java 8 or later. slf4j-api is needed only when Slf4jLogger is used.
Full changelog: v1.1...v1.2