Bitryon Logger Docs
GitHub
API Reference

Logger

The primary interface for writing logs.

Reference

// In Java
	private static final Logger logger = LoggerFactory.getLogger();
	logger.log();
	
//In spring
@Configuration
@Import(value= {
	AutoConfigurationBitryonLogger.class, // to load the configs from application.yml for logging related beans
})
public class ExampleWebServerConfiguration {

	@Resource
	Logger logger;
}

Methods

MethodDescription
flush()flush the logs into persistence.
skip(boolean skip)Setup if the logging should skip. true skipped, false not.
boolean getSkip()To indicate if the logging is skipped.
reset()before or after enter a thread to process logics, to clean up context.
setStepLogId(String stepLogId, boolean sequenceIdRenewal)

If the thread is created by another un-related thread, it needs to setup the log id manually in order to trace.
if the trace id part is longer than 32, it will use substring(0, 32).
@param stepLogId setup step log id. should be traceId + sequenceId: 4ouOhT4RN5jcGxJTCJRn4eOWfjyNZ07L-5-2-1
@param sequenceIdRenewal true the sequence id will be renewal, otherwise will increase based on the current sequence id from the stepLogId

setStepLogId(String stepLogId)

If the thread is created by another un-related thread, it needs to setup the log id manually in order to trace.
the sequence id will be renewal by default
The characters are not 0-9a-zA-z- will be moved. the trace id part is longer than 32 will be substring(0, 32).
@param stepLogId setup step log id. should be traceId + sequenceId: 4ouOhT4RN5jcGxJTCJRn4eOWfjyNZ07L-5-2-1

String getStepLogId() Get the step log id.
@return E.G. 4ouOhT4RN5jcGxJTCJRn4eOWfjyNZ07L-5-2-1
String getNextStepLogId() Get the next step log id used for a new step. should call getStepLogId() if used for an inside invoke.
@return E.G. 4ouOhT4RN5jcGxJTCJRn4eOWfjyNZ07L-5-2-1 -> 4ouOhT4RN5jcGxJTCJRn4eOWfjyNZ07L-5-2-2
String getTraceId() trace id, should be 32 characters consist of 0-1a-zA-Z only.
@return E.G. 4ouOhT4RN5jcGxJTCJRn4eOWfjyNZ07L
log(Object... objects) log objects as PreDefinition.TYPE.JSON. For most cases, it's enough for use.
@param objects values to log
text(String textMessage, Object... objects) write text message with PreDefinition.TYPE.TEXT, and replace the message by placeholder {}.
logText("this is a {}, {} has it", "apple", "joe") -> "this is a apple, joe has it"
For most cases, it's enough for use.
@param textMessage text message with formats
@param objects values to log. Should only be simple types like number or string.
ret(String step, Object... objects) [Not recommended] write a return log. In general return log would be pair to the enter log.
@param step If null, trace back with the stack by default skipLayer; or write the string including empty "",
@param objects The first should be the return values, then comes the parameters if configured in @Logger; values to transform by PreDefinition.TYPE indicated
exception(Throwable throwable) log exceptions with PreDefinition.TYPE.EXCEP.
@param throwable the exception, may log multiple lines
💡Note For most of cases, log() and text() are well enough. Others methods are for specific usage.

bitryon logger believes log levels is out-dated. So it provides skip and skipRandom instead.