Brief
Add support for multiple log handlers to forward log into different log assembly line.
Why?
It's a common senario to print logs to multiple outputs with different config.
Example API
This is merely a simple demonstration; the specific API selection requires further consideration.
Logger logger = Logger();
LoggerHandler fileHandler = LoggerHandler(
printer: SimplePrinter(),
filter: ProductionPrinter(LogLevel.Info),
output: FileOutput("foo.log"),
);
logger.addHandler(fileHandler);
LoggerHandler consoleHandler = LoggerHandler(
printer: PrefixPrinter(PrettyPrinter()),
filter: DevelopmentPrinter(LogLevel.Info),
output: ConsoleOutput(),
);
logger.addHandler(consoleHandler);
And, when calling log functions, e.g. logger.i("hello world!"), the output will be forwarded to both handler.
This could be implemented with two separate Logger with a manager now.
Reference
See python's logging module for more (possible) use cases.
Brief
Add support for multiple log handlers to forward log into different log assembly line.
Why?
It's a common senario to print logs to multiple outputs with different config.
Example API
And, when calling log functions, e.g.
logger.i("hello world!"), the output will be forwarded to both handler.This could be implemented with two separate
Loggerwith a manager now.Reference
See python's
loggingmodule for more (possible) use cases.