CleverLogger class
A logger that prints colorful logs by default.
The logger can log messages in different levels.
Example
final logger = CleverLogger('Test Logger');
logger.logInfo('This is a info');
logger.logWarning('This is a warning');
You can also define actions for the logs.
final loggerWithCustomActions = CleverLogger(
'Test Logger',
logActions: [
ColorfulPrintAction(),
// Your custom action
// (Actions can be configured to only be triggered when the log has a certain level)
MySendToFirebaseAction(),
],
);
Alternatively you can use the defaultLogger
by just calling log (or logInfo, logWarning etc.).
See also:
- LogAction an action taken with the log. You can extend this class for custom actions.
- ColorfulPrintAction the default action used for this logger. You can customize its printer argument for a customized color output.
- Available extensions
Constructors
-
CleverLogger.new(String name, {List<
LogAction> logActions = const [ColorfulPrintAction()], bool shouldLog = true}) - A logger that prints colorful logs by default.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shouldLog → bool
-
The value of shouldLog determines whether
or not events should be logged.
final
-
values
→ Map<
String, dynamic> -
Additional values stored in this logger.
Can be used to store data for extension methods.
final
Methods
-
finishWatch(
) → void -
Available on CleverLogger, provided by the StopwatchExtension extension
Stop and reset the Stopwatch and log its results. -
log(
Object? message, [Level level = Level.FINE]) → void -
Logs a message at
level
. -
logConfig(
Object? message) → void - Logs a message at Level.CONFIG.
-
logFine(
Object? message) → void - Logs a message at Level.FINE.
-
logInfo(
Object? message) → void - Logs a message at Level.INFO.
-
logSevere(
Object? message) → void - Logs a message at Level.SEVERE.
-
logShout(
Object? message) → void - Logs a message at Level.SHOUT.
-
logWarning(
Object? message, {Object? error, StackTrace? stackTrace}) → void - Logs a message at Level.WARNING.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pauseWatch(
) → void -
Available on CleverLogger, provided by the StopwatchExtension extension
Stops a Stopwatch in this logger. -
startWatch(
) → void -
Available on CleverLogger, provided by the StopwatchExtension extension
Starts a Stopwatch in this logger. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited