Skip to content

Instantly share code, notes, and snippets.

@JaveedIshaq
Last active March 29, 2020 17:05
Show Gist options
  • Save JaveedIshaq/b6d5091cd6ca0fb7a4622c6b016c2907 to your computer and use it in GitHub Desktop.
Save JaveedIshaq/b6d5091cd6ca0fb7a4622c6b016c2907 to your computer and use it in GitHub Desktop.
Customs Logger class Flutter with logger: ^0.8.3 https://github.com/leisim/logger
import 'package:logger/logger.dart';
Logger getLogger(String className) {
return Logger(printer: SimpleLogPrinter(className));
}
class SimpleLogPrinter extends LogPrinter {
final String className;
SimpleLogPrinter(this.className);
@override
List<String> log(LogEvent event) {
AnsiColor color = PrettyPrinter.levelColors[event.level];
String emoji = PrettyPrinter.levelEmojis[event.level];
return [color('$emoji [$className]: ${event.message}')];
}
}
// in class simple import this class
// and write ... Logger log = getLogger("ClasssName");
//log.v("This is a verbose");
//log.d("this is a debug message");
//log.i("This is info, should be used for public calls");
//log.w("This might become problem: a warning message");
//log.e("This is the error message");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment