getStepValue method
Extracts the string representation of the given LogStep from a LogRecord.
Returns null if the step is disabled or the corresponding data is unavailable.
Implementation
@override
String? getStepValue(LogStep step, LogRecord record) {
switch (step) {
case LogStep.LEVEL:
return config.showLevel ? 'level=${record.level.name.toLowerCase()}' : null;
case LogStep.MESSAGE:
return 'msg="${_escapeString(record.message)}"';
case LogStep.TIMESTAMP:
if (!config.showTimestamp) return null;
final time = config.useHumanReadableTime
? LogCommons.formatTimestamp(record.time, true)
: record.time.toIso8601String();
return 'time="$time"';
case LogStep.DATE:
if (!config.showDateOnly || !config.showTimestamp) return null;
final date = record.time.toIso8601String().split('T')[0];
return 'date="$date"';
case LogStep.TAG:
return (config.showTag && record.loggerName != null && record.loggerName!.isNotEmpty)
? 'logger="${_escapeString(record.loggerName!)}"'
: null;
case LogStep.ERROR:
return (record.error != null)
? 'error="${_escapeString(record.error.toString())}"'
: null;
case LogStep.STACKTRACE:
return (record.stackTrace != null)
? 'stacktrace="${_escapeString(record.stackTrace.toString())}"'
: null;
case LogStep.THREAD:
return config.showThread ? 'thread="main"' : null;
case LogStep.LOCATION:
if (!config.showLocation) return null;
final location = record.location;
return location != null ? 'location="$location"' : null;
}
}