log static method
- String msg, {
- DevLevel level = DevLevel.normal,
- bool? isLog,
- int? colorInt,
- String? fileLocation,
- DateTime? time,
- int? sequenceNumber,
- String? name,
- Zone? zone,
- Object? error,
- StackTrace? stackTrace,
- bool? execFinalFunc,
- String? printOnceIfContains,
- int debounceMs = 0,
- String? debounceKey,
- String? tag,
Default color log
@parammsg: The message string to be logged
@paramlevel: The log level (verbose, normal, info, success, warn, error, fatal), defaults to normal
@paramisLog: If set to true, logs regardless of the static enable flag
@paramcolorInt: ANSI color code (0 to 107) for text color customization
@paramfileLocation: Custom file location string; if null, auto-detects from stack trace
@paramtime: Custom timestamp for the log; if null, uses current time
@paramsequenceNumber: Sequence number for log ordering
@paramname: Custom name/tag for the log entry; if null, uses the level name
@paramzone: Dart Zone where the log originates from
@paramerror: Associated error object to be logged alongside the message
@paramstackTrace: Stack trace information for debugging
@paramexecFinalFunc: If true, executes the custom final function exeFinalFunc
@paramprintOnceIfContains: If provided, only prints once when message contains this keyword
@paramdebounceMs: Debounce time interval in milliseconds, logs within this interval will be discarded
@paramdebounceKey: Custom key for debounce identification (if not provided, uses msg|devLevel|name as fallback)
@paramtag: Tag for show and filtering; displayed in log output, and when isFilterByTags is true, only logs with tags matching tags are displayed
Implementation
static void log(
String msg, {
DevLevel level = DevLevel.normal,
bool? isLog,
int? colorInt,
String? fileLocation,
DateTime? time,
int? sequenceNumber,
String? name,
Zone? zone,
Object? error,
StackTrace? stackTrace,
bool? execFinalFunc,
String? printOnceIfContains,
int debounceMs = 0,
String? debounceKey,
String? tag,
}) {
int ci = colorInt ??
(_logColorMap[level] ??
(defaultColorInt ?? (isMultConsoleLog ? 4 : 0)));
// Performance optimization: Get file location and tag in a single stack trace call
final stackInfo = fileLocation == null ? _getStackTraceInfo() : null;
final String fileInfo = fileLocation != null
? '($fileLocation): '
: (stackInfo?.fileLocation ?? '');
final levelMap = {DevLevel.warn: 1000, DevLevel.error: 2000};
final theName = name ?? level.alias.split('.').last;
// Use tag from unified stack trace if not provided
final effectiveTag = tag ?? stackInfo?.tag;
DevColorizedLog.logCustom(
msg,
devLevel: level,
enable: Dev.enable,
colorInt:
execFinalFunc != null && execFinalFunc ? _exeColorMap[level]! : ci,
isLog: isLog,
fileInfo: fileInfo,
time: time,
sequenceNumber: sequenceNumber,
level: levelMap[level] ?? 0,
name: theName,
zone: zone,
error: error,
stackTrace: stackTrace,
execFinalFunc: execFinalFunc,
printOnceIfContains: printOnceIfContains,
debounceMs: debounceMs,
debounceKey: debounceKey,
tag: effectiveTag,
);
}