Dev class

Dev - A flexible and colorized logging utility for Flutter/Dart development

This class provides various logging methods with customizable colors, levels, and advanced features like debouncing, one-time printing, and custom final functions.

Configuration properties:

Constructors

Dev()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

customFinalFunc ↔ dynamic Function(String, DevLevel)?
@deprecated Use exeFinalFunc instead. This will be removed in future versions.
getter/setter pair
defaultColorInt int?
Default ANSI color code (0-107) for log text If not specified, uses default colors based on log level
getter/setter pair
enable bool
Global switch to enable or disable all logging When false, logs are suppressed unless overridden by individual log calls with isLog: true
getter/setter pair
exeFinalFunc ↔ dynamic Function(String, DevLevel)?
Custom final function to execute when log level meets the threshold specified by exeLevel Takes two parameters: the log message string and the DevLevel Useful for custom log processing, remote logging, or error reporting
getter/setter pair
exeLevel DevLevel
The lowest level threshold to execute the function exeFinalFunc Only logs at or above this level will trigger the final function Default is warn (executes for warn, error, and fatal levels)
getter/setter pair
isDebugPrint bool?
Controls whether Dev.print method prints only in debug mode If null, prints in all modes; if true, prints only in debug mode; if false, prints in all modes
getter/setter pair
isExeDiffColor bool
Whether to use different background colors when executing final function When true, uses background colors instead of text colors for exeFinalFunc execution
getter/setter pair
isExeWithDateTime bool
Whether to include timestamp when executing the final function exeFinalFunc When true, timestamp is passed to the final function
getter/setter pair
isExeWithShowLog bool
Whether to show log output when executing the final function exeFinalFunc When true, logs are displayed in console even when final function is executed
getter/setter pair
isLightweightMode bool
Lightweight mode: Skip stack trace capture completely for production When enabled, file location logging is disabled for maximum performance Recommended for production environments where logging performance is critical
getter/setter pair
isLogFileLocation bool
Whether to log file location information in the output When true, logs include file name and line number like "(main.dart:42):"
getter/setter pair
isLogShowDateTime bool
Whether to display timestamp in log output When true, logs include date and time information
getter/setter pair
isMultConsoleLog bool
Whether to use multi-console logging mode When true, uses enhanced formatting suitable for multiple console outputs
getter/setter pair
isReplaceNewline bool
Whether to replace newline characters and clean up whitespace for better search visibility in console When true, newline characters are replaced with newlineReplacement string
getter/setter pair
logLevel DevLevel
The lowest level threshold to print logs to console Logs below this level will be filtered out and not displayed Default is verbose (prints all logs)
getter/setter pair
newlineReplacement String
The replacement string for newline characters when isReplaceNewline is true Default is ' | ' to maintain readability while keeping logs on a single line
getter/setter pair
prefixName String
Prefix string prepended to all log messages Useful for distinguishing logs from different modules or components
getter/setter pair
useOptimizedStackTrace bool
Use optimized stack trace parsing (stack_trace package) When enabled (default), uses the stack_trace package for better performance (40-60% faster) When disabled, uses basic string operations (still 10-20% faster than original)
getter/setter pair

Static Methods

addCachedKey(String key) → void
Add a keyword to the cache to mark it as logged @paramkey: The keyword to add to the cache After adding, subsequent logs containing this keyword will be suppressed when using printOnceIfContains
clearCachedKeys() → void
Clear all cached keywords to allow repeated logging Removes all entries from the one-time print cache Useful for resetting the print-once state during testing or at application restart
clearDebounceTimestamps() → void
Clear all debounce timestamps to reset debounce state Removes all entries from the debounce cache, allowing all debounced logs to fire immediately Useful for resetting the debounce state during testing or at application restart
exe(String msg, {String? name, DevLevel level = DevLevel.normal, bool? isLog, bool? isMultConsole, bool? isDebug, int? colorInt, String? fileInfo, Object? error, StackTrace? stackTrace, String? printOnceIfContains, int debounceMs = 0, String? debounceKey}) → void
Execute custom final func with purple text or blue text with multiple consoles @parammsg: The message string to be logged @paramname: Custom name/tag for the log entry; if null, uses the level name (with prefix for multi-console) @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 @paramisMultConsole: If true, enables multi-console logging mode with dbgPrt/unlPrt prefix @paramisDebug: If true, prints only on debug mode; if null, uses static isDebugPrint @paramcolorInt: ANSI color code (0 to 107) for text color customization @paramfileInfo: Custom file location string; if null, auto-detects from stack trace @paramerror: Associated error object to be logged alongside the message @paramstackTrace: Stack trace information for debugging @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)
exeError(String msg, {bool? isLog, bool? isMultConsole, bool? isDebug, int? colorInt, Object? error, StackTrace? stackTrace, String? printOnceIfContains, int debounceMs = 0, String? debounceKey}) → void
Execute error level log with custom final function @parammsg: The message string to be logged @paramisLog: If set to true, logs regardless of the static enable flag @paramisMultConsole: If true, enables multi-console logging mode @paramisDebug: If true, prints only on debug mode; if null, uses static isDebugPrint @paramcolorInt: ANSI color code (0 to 107) for text color customization @paramerror: Associated error object to be logged alongside the message @paramstackTrace: Stack trace information for debugging @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)
exeFatal(String msg, {bool? isLog, bool? isMultConsole, bool? isDebug, int? colorInt, String? printOnceIfContains, int debounceMs = 0, String? debounceKey}) → void
Execute fatal level log with custom final function @parammsg: The message string to be logged @paramisLog: If set to true, logs regardless of the static enable flag @paramisMultConsole: If true, enables multi-console logging mode @paramisDebug: If true, prints only on debug mode; if null, uses static isDebugPrint @paramcolorInt: ANSI color code (0 to 107) for text color customization @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)
exeInfo(String msg, {bool? isLog, bool? isMultConsole, bool? isDebug, int? colorInt, String? printOnceIfContains, int debounceMs = 0, String? debounceKey}) → void
Execute info level log with custom final function @parammsg: The message string to be logged @paramisLog: If set to true, logs regardless of the static enable flag @paramisMultConsole: If true, enables multi-console logging mode @paramisDebug: If true, prints only on debug mode; if null, uses static isDebugPrint @paramcolorInt: ANSI color code (0 to 107) for text color customization @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)
exeSuccess(String msg, {bool? isLog, bool? isMultConsole, bool? isDebug, int? colorInt, String? printOnceIfContains, int debounceMs = 0, String? debounceKey}) → void
Execute success level log with custom final function @parammsg: The message string to be logged @paramisLog: If set to true, logs regardless of the static enable flag @paramisMultConsole: If true, enables multi-console logging mode @paramisDebug: If true, prints only on debug mode; if null, uses static isDebugPrint @paramcolorInt: ANSI color code (0 to 107) for text color customization @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)
exeVerbose(String msg, {bool? isLog, bool? isMultConsole, bool? isDebug, int? colorInt, String? printOnceIfContains, int debounceMs = 0, String? debounceKey}) → void
Execute verbose level log with custom final function @parammsg: The message string to be logged @paramisLog: If set to true, logs regardless of the static enable flag @paramisMultConsole: If true, enables multi-console logging mode @paramisDebug: If true, prints only on debug mode; if null, uses static isDebugPrint @paramcolorInt: ANSI color code (0 to 107) for text color customization @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)
exeWarn(String msg, {bool? isLog, bool? isMultConsole, bool? isDebug, int? colorInt, String? printOnceIfContains, int debounceMs = 0, String? debounceKey}) → void
Execute warn level log with custom final function @parammsg: The message string to be logged @paramisLog: If set to true, logs regardless of the static enable flag @paramisMultConsole: If true, enables multi-console logging mode @paramisDebug: If true, prints only on debug mode; if null, uses static isDebugPrint @paramcolorInt: ANSI color code (0 to 107) for text color customization @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)
exeWarning(String msg, {bool? isLog, bool? isMultConsole, bool? isDebug, int? colorInt, String? printOnceIfContains, int debounceMs = 0, String? debounceKey}) → void
@deprecated Use exeWarn instead. This will be removed in future versions. Execute warning level log with custom final function (deprecated) @parammsg: The message string to be logged @paramisLog: If set to true, logs regardless of the static enable flag @paramisMultConsole: If true, enables multi-console logging mode @paramisDebug: If true, prints only on debug mode; if null, uses static isDebugPrint @paramcolorInt: ANSI color code (0 to 107) for text color customization @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)
hasCachedKey(String key) bool
Check if a keyword has been cached (logged once) @paramkey: The keyword to check in the cache @return: Returns true if the keyword has been logged before, false otherwise Used with printOnceIfContains parameter to prevent duplicate log messages
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}) → void
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)
logError(String msg, {bool? isLog, bool? execFinalFunc, Object? error, StackTrace? stackTrace, String? printOnceIfContains, int debounceMs = 0, String? debounceKey}) → void
Error - Red text for error messages @parammsg: The message string to be logged @paramisLog: If set to true, logs regardless of the static enable flag @paramexecFinalFunc: If true, executes the custom final function exeFinalFunc @paramerror: Associated error object to be logged alongside the message @paramstackTrace: Stack trace information for debugging @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)
logFatal(String msg, {bool? isLog, bool? execFinalFunc, String? printOnceIfContains, int debounceMs = 0, String? debounceKey}) → void
Fatal/Critical error - text (orange/purple) Use for fatal errors that require immediate attention @parammsg: The message string to be logged @paramisLog: If set to true, logs regardless of the static enable flag @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)
logInfo(String msg, {bool? isLog, bool? execFinalFunc, String? printOnceIfContains, int debounceMs = 0, String? debounceKey}) → void
Info - Blue text for informational messages @parammsg: The message string to be logged @paramisLog: If set to true, logs regardless of the static enable flag @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)
logSuccess(String msg, {bool? isLog, bool? execFinalFunc, String? printOnceIfContains, int debounceMs = 0, String? debounceKey}) → void
Success - Green text for success/completion messages @parammsg: The message string to be logged @paramisLog: If set to true, logs regardless of the static enable flag @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)
logVerbose(String msg, {bool? isLog, bool? execFinalFunc, String? printOnceIfContains, int debounceMs = 0, String? debounceKey}) → void
Verbose - Dark gray text for detailed debug information Use for verbose debugging details @parammsg: The message string to be logged @paramisLog: If set to true, logs regardless of the static enable flag @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)
logWarn(String msg, {bool? isLog, bool? execFinalFunc, String? printOnceIfContains, int debounceMs = 0, String? debounceKey}) → void
Warn - Yellow text for warning messages @parammsg: The message string to be logged @paramisLog: If set to true, logs regardless of the static enable flag @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)
logWarning(String msg, {bool? isLog, bool? execFinalFunc, String? printOnceIfContains, int debounceMs = 0, String? debounceKey}) → void
@deprecated Use logWarn instead. This will be removed in future versions. Warning - Yellow text for warning messages (deprecated, use logWarn) @parammsg: The message string to be logged @paramisLog: If set to true, logs regardless of the static enable flag @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)
print(Object? object, {String? name, DevLevel level = DevLevel.normal, int? colorInt, bool? isLog, String? fileLocation, bool? isDebug, bool? execFinalFunc, Object? error, StackTrace? stackTrace, String? printOnceIfContains, int debounceMs = 0, String? debounceKey}) → void
Log supporting on multiple consoles @paramobject: The object to be logged (will be converted to string) @paramname: Custom name/tag for the log entry; if null, uses the level name with dbgPrt/unlPrt prefix @paramlevel: The log level (verbose, normal, info, success, warn, error, fatal), defaults to normal @paramcolorInt: ANSI color code (0 to 107) for text color customization @paramisLog: If set to true, logs regardless of the static enable flag @paramfileLocation: Custom file location string; if null, auto-detects from stack trace @paramisDebug: If true, prints only on debug mode; if null, uses static isDebugPrint @paramexecFinalFunc: If true, executes the custom final function exeFinalFunc @paramerror: Associated error object to be logged alongside the message @paramstackTrace: Stack trace information for debugging @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)
shouldDebounce(String key, int debounceMs) bool
Check if a log should be debounced based on time interval @paramkey: The debounce key to identify the log entry @paramdebounceMs: Debounce interval in milliseconds @return: Returns true if the log should be skipped (still in debounce period), false to allow logging