Log constructor
Log(
- String tag
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
Implementation
factory Log(String tag) {
if (!_logs.containsKey(tag)) {
_logs[tag] = Log._(tag.padRight(25));
}
return _logs[tag]!;
}