Log - Kibibibit/geoff GitHub Wiki
Log contains an extended console logger with colours and varying log levels.
API
Enums
Level
The various levels that the logger can log at. Logs will be coloured and include an icon based on the level.
| Value | Colour | Icon |
|---|---|---|
info |
Blue | Icons.lightbulb |
warning |
Yellow | Icons.warning |
error |
Red | Icons.error |
debug |
Green | Icons.bug_report |
nothing |
N/A | N/A |
Setting the logger to Level.nothing will disable logs. |
Static Methods
static void showLogger(BuildContext context)
Brings up a page in app that shows the console output.
Constructor
Log(String name, {Level level, bool colors})
Creates a new Log with name. level sets the initial log level of the Log, and setting colors to false disables colours. level defaults to Level.info and colors defaults to true.
Methods
void log(dynamic message, [Error? error, StackTrace? stackTrace])
Logs message to the console, at the currently set Level. Optional errors and stacktraces can be included with error and stackTrace
void logAt(Level level, dynamic message, [Error? error, StackTrace? stackTrace])
Same as log, but you can set the Level through level.
void info(dynamic message, [Error? error, StackTrace? stackTrace])
Calls logAt at Level.info.
void warning(dynamic message, [Error? error, StackTrace? stackTrace])
Calls logAt at Level.warning.
void error(dynamic message, [Error? error, StackTrace? stackTrace])
Calls logAt at Level.error.
void debug(dynamic message, [Error? error, StackTrace? stackTrace])
Calls logAt at Level.debug.
setLogInDebugMode(bool log)
If log is set to true, logs will still show up even when the app is not in debug mode.
setMaxLogs(int maxLogs)
Sets the amount of logs that will be shown in the in-app console. Defaults to 100, cannot be less than 0.
setIconSize(double iconSize)
Sets the icon size of the icons shown in the in-app console. Defaults to 24.0, cannot be less than 0.
void setColors(bool colors)
Setting this to false will stop colours from showing up the console. Colours are handled through escape codes so disable colours if your console does not support it.
void setLevel(Level level)
Sets the default Level used when log is called. Setting this to Level.nothing will disable logs.
Getters
String get name
Returns the name of this logger.
Level get level
Returns the current Level this logger is using.
bool get colors
Returns true if this logger is using colours.
int get maxLogs
Returns the amount of logs being stored in the in-app console.
double get iconSize
Returns the icon size shown in the in-app console.
bool get logInDebugMode
Returns true if the logger will show logs even when the app is in release mode