Closed diegocatalao closed 7 months ago
No, there are currently no plans, but this doesn't mean we won't add some additional fields in the future. I guess it should be possible to get at least some of these information from the StackTrace of the log call.
As a "now" solution, you could inspect the OutputEvent
and get the StackTrace from the original LogEvent
and extract it yourself until there is a standardized solution.
We are also open for Pull Requests!
Great!
I've been thinking about making a small modification to the log function at L129 with StackTrace.current parser like without too much text manipulation. Anything added there would increase the runtime a bit, anyway.
// ...
class OutputEvent {
final List<String> lines;
final LogEvent origin;
final String? filepath;
final String? filename;
final String? funcname;
final int? lineno;
Level get level => origin.level;
OutputEvent(
this.origin,
this.lines, [
this.filepath,
this.filename,
this.funcname,
this.lineno,
]);
}
// ...
String clipFilepath(StackTrace currentStackTrace) {
// ...
}
String clipFilename(StackTrace currentStackTrace) {
// ...
}
String clipFuncname(StackTrace currentStackTrace) {
// ...
}
int clipLineno(StackTrace currentStackTrace) {
// ...
}
// ...
if (output.isNotEmpty) {
var currentStackTrace = StackTrace.current;
var outputEvent = OutputEvent(
logEvent,
output,
clipFilepath(currentStackTrace),
clipFilename(currentStackTrace),
clipFuncname(currentStackTrace),
clipLineno(currentStackTrace),
);
// Issues with log output should NOT influence
// the main software behavior.
Anyway, we create a fork and will add it to this thread. Thanks for the answer!
I would like to make such a feature opt-in, like with a specific printer, to avoid impacting current users.
Small note: Re-using the provided StackTrace instead of creating a new one should improve the performance.
Hello, folks! Thank you for maintaining this project.
I would like to know if there is any prediction in the future to implement more information in the
LogEvent
class. In some logger implementations like Python, whoseLogRecord
equivalent, some information is passed aslineno
,module
,funcName
, etc. It would be interesting because it would be used when issuing a log to some other log system like DataDog or Graylog.