Closed lomby92 closed 4 months ago
Why would you want to remove it?
If you don't like it/need it, you can disable it via the constructor parameter printTime
.
I want the time as hours, minutes, seconds etc but I don't want to see TIME: on each log line
Then I guess you have to extend the SimplePrinter and modify it to your requirements. I can't just change the output for all users.
Seems reasonable. I asked only because is not so common to have a generic string repeated many times in loggers.
For example: https://github.com/pinojs/pino-pretty
[17:35:28.992] INFO (42): hello world
But also in PHP and in other languages/systems.
Anyway, it's easy to create a custom Output so this is not a real problem. Thanks
If anyone in the future will need it:
/// Override the default SimplePrinter to customize the log output
/// without the noisy "TIME: " prefix on DateTime.
final class CustomSimplePrinter extends SimplePrinter {
CustomSimplePrinter({printTime = false, colors = true})
: super(printTime: printTime, colors: colors);
@override
List<String> log(LogEvent event) {
List<String> logs = super.log(event);
if (!printTime) {
return logs;
}
return logs.map((l) => l.replaceAll('TIME: ', '')).toList();
}
}
I've tried SimplePrinter but IMO is not that simple since it adds a noisy "TIME:" string to each line. Do you think that it should be removed?
In case, i will open a PR