log static method

void log(
  1. String msg, {
  2. DevLevel level = DevLevel.normal,
  3. bool? isLog,
  4. int? colorInt,
  5. String? fileLocation,
  6. DateTime? time,
  7. int? sequenceNumber,
  8. String? name,
  9. Zone? zone,
  10. Object? error,
  11. StackTrace? stackTrace,
  12. bool? execFinalFunc,
  13. String? printOnceIfContains,
  14. int debounceMs = 0,
  15. String? debounceKey,
})

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)

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,
}) {
  int ci = colorInt ??
      (_logColorMap[level] ??
          (defaultColorInt ?? (isMultConsoleLog ? 4 : 0)));
  final String fileInfo =
      fileLocation != null ? '($fileLocation): ' : _getFileLocation();
  final levelMap = {DevLevel.warn: 1000, DevLevel.error: 2000};
  final theName = name ?? level.toString().split('.').last;

  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,
  );
}