Logs class
A logger class that conditionally stores logs, traces and prints them to the console
Instantiate this class and use the methods to log messages
Use includeTrace to include the stack trace in the log. Note that this will use more memory, and should be used only for debugging purposes
Example:
final log = Logs();
log.v('Verbose log');
log.d('Debug log');
log.i('Info log');
log.w('Warning log');
log.e('Error log', includeTrace: true);
Additional configuration:
- storeLogLevel: The minimum log level to store in the logs list
- printLogLevelWhenDebug: The minimum log level to print when running in debug mode
- printLogLevelWhenRelease: The minimum log level to print when running in release mode
- storeLimit: The maximum number of logs to store in memory
Example:
final log = Logs(
storeLogLevel: LogLevel.verbose,
printLogLevelWhenDebug: LogLevel.verbose,
printLogLevelWhenRelease: LogLevel.error,
storeLimit: 500,
);
log.v('Verbose log');
Use getStoredLogs to get the stored logs as a list
Example:
final log = Logs();
log.v('Verbose log');
log.d('Debug log');
List<Map> logs = log.getStoredLogs();
Constructors
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
-
d(
dynamic message, {bool includeTrace = false}) → void - Log a debug message
-
e(
dynamic message, {bool includeTrace = false}) → void - Log an error message
-
getStoredLogs(
{int limit = 100}) → List< Map> - Get the stored logs as a list of maps
-
i(
dynamic message, {bool includeTrace = false}) → void - Log an info message
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
v(
dynamic message, {bool includeTrace = false}) → void - Log a verbose message
-
w(
dynamic message, {bool includeTrace = false}) → void - Log a warning message
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited