Skip to content

Wrap SLF4J logger to provide a simpler format mechanism.

Notifications You must be signed in to change notification settings

Raphcal/logdorak

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logdorak

Wrap SLF4J logger to provide a simpler format mechanism.

Line endings in logged messages are stripped to avoid log injection.

Usage

Logdorak Logger methods takes an object array as argument.

If the last argument is a Throwable, it will be given as is to SLF4J. Every other argument will be turned into a String using Objects.toString, stripped from any \r or \n character and joined together to be used as the message.

Example

public class Thermostat {
  private static final Logger LOGGER = new Logger(Thermostat.class);

  public void setTemperature(int temperature) {
    LOGGER.trace("Will set the temperature to ", temperature, "°C.");
    try (Connector connector = new Connector()) {
      connector.setTemperature(temperature);
      LOGGER.info("Temperature has been set to ", temperature, "°C.")
    } catch (IOException e) {
      LOGGER.error("Unable to set the temperature to ", temperature, "°C", e);
    }
  }
}

About

Wrap SLF4J logger to provide a simpler format mechanism.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages