Log class

Used to print logs in the console according to the severity level of the logging text.

Log instance can be created by providing a tag, which is used to separate log instances. You can't create two instances with the same tag.

class UserRepository {
  // Create a instance of the log with a tag
  static final log = Log("UserRepository");

  Future<void> add(Item item) async {
    log.d("Adding the item with name: ${item.name});
    // ...
  }
}

By changing the level of the Log instance, you can decide the severity level that is printed. Default value is debug. That means every log that has severity level of debug or higher will be printed.

Severity level from higher to lower can be ordered as follows

Annotations

Constructors

Log(String tag)
Used to print logs in the console according to the severity level of the logging text.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
tag String
tag is given while creating a instance of the Log. If a instance has previously created with the same tag, the same instance will be return. Else new instance will be created.
final

Methods

d(String message) → void
Used to log a message with debug severity level.
e(String message) → void
Used to log a message with error severity level.
i(String message) → void
Used to log a message with info severity level.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
w(String message) → void
Used to log a message with warn severity level.

Operators

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

Static Properties

level int
Used to store the current severity level of the Log instances. Default level is debug.
getter/setter pair

Constants

critical → const int
Severity level of critical
debug → const int
Severity level of debug.
error → const int
Severity level of error.
info → const int
Severity level of info.
off → const int
Turn off logging
warn → const int
Severity level of warn.