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) {
final color = levelColor(record.level);
switch (step) {
case LogStep.TIMESTAMP:
if (!config.showTimestamp) return null;
return config.useHumanReadableTime
? LogCommons.formatTimestamp(record.time, true)
: record.time.toIso8601String();
case LogStep.DATE:
if (!config.showDateOnly || !config.showTimestamp) return null;
return record.time.toIso8601String().split('T')[0];
case LogStep.LEVEL:
return config.showLevel ? color(record.level.name) : null;
case LogStep.TAG:
return (config.showTag && record.loggerName != null && record.loggerName!.isNotEmpty) ? record.loggerName : null;
case LogStep.MESSAGE:
return stringify(record.message);
case LogStep.ERROR:
return (record.error != null) ? 'ERROR: ${record.error}' : null;
case LogStep.THREAD:
return config.showThread ? LogCommons.formatElapsed(Duration.zero) : null;
case LogStep.LOCATION:
if (!config.showLocation) return null;
final location = record.location;
return location != null ? 'LOC:$location' : null;
case LogStep.STACKTRACE:
return null; // Handled separately
}
}