Logger class

The Logger class is a simple class for printing information on the terminal only when the application is in debug mode.

Below is an example of implementing the logger.

final Logger logger = Logger();

logger.log('simple log');
/// output: simple log

logger.info('information log');
/// output: 💡 information log

logger.warning('warning log');
/// output: ⚠️ warning log

logger.error('error log');
/// output: ⛔ error log

If it is necessary to add a prefix when printing all logs, use the prefix parameter in the class's constructor.

Constructors

Logger({String? prefix})
Standard constructor of the Logger class

Properties

hashCode → int
The hash code for this object.
no setterinherited
inDebugMode → bool
Indicates if the app is running in debug mode
final
prefix → String?
Logger prefix.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

error(String message) → void
info(String message) → void
log(String message) → void
Print a log message if the application is in debug mode
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
warning(String message) → void

Operators

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