dev.qadenz.automation.logs.ConsoleLogLayout Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of qadenz Show documentation
Show all versions of qadenz Show documentation
A robust test automation library.
/*
Copyright Tim Slifer
Licensed under the PolyForm Internal Use License, Version 1.0.0 (the "License");
you may not use this file except in compliance with the License.
A copy of the License may be obtained at
https://polyformproject.org/licenses/internal-use/1.0.0/
*/
package dev.qadenz.automation.logs;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.CoreConstants;
import ch.qos.logback.core.LayoutBase;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Defines a Logback log event layout to be used for the Console loggers.
*
* @author Tim Slifer
*/
public class ConsoleLogLayout extends LayoutBase {
@Override
public String doLayout(ILoggingEvent event) {
return new SimpleDateFormat("HH:mm:ss:SSS").format(new Date()) + " | " +
"Thread: " + event.getThreadName().substring(event.getThreadName().lastIndexOf("-") + 1) + " | " +
event.getLevel() + " | " +
event.getLoggerName().substring(event.getLoggerName().lastIndexOf(".") + 1) + " | " +
event.getFormattedMessage() + CoreConstants.LINE_SEPARATOR;
}
}