codenic_logger 0.1.0 codenic_logger: ^0.1.0 copied to clipboard
An extended logger for providing detailed log messages.
import 'package:codenic_logger/codenic_logger.dart';
final codenicLogger = CodenicLogger();
const messageLog = MessageLog(message: 'Sample message');
void main() {
// To run, type `dart --enable-asserts example/main.dart`.
verboseWithUserId();
verbose();
debug();
info();
warn();
error();
wtf();
}
void verboseWithUserId() {
codenicLogger.userId = 'sample-uid';
codenicLogger.info(
messageLog.copyWith(details: 'verbose'),
data: {'foo': false, 'lorep': 'ipsum'},
);
codenicLogger.userId = null;
}
void verbose() {
codenicLogger.verbose(
messageLog.copyWith(details: 'verbose'),
data: {'foo': false, 'lorep': 'ipsum'},
);
}
void debug() {
codenicLogger.debug(
messageLog.copyWith(details: 'debug'),
data: {'foo': false, 'lorep': 'ipsum'},
);
}
void info() {
codenicLogger.info(
messageLog.copyWith(details: 'info'),
data: {'foo': false, 'lorep': 'ipsum'},
);
}
void warn() {
try {
throw Exception('Test exception');
} catch (exception, stackTrace) {
codenicLogger.warn(
messageLog.copyWith(details: 'warn'),
data: {'foo': false, 'lorep': 'ipsum'},
error: exception,
stackTrace: stackTrace,
);
}
}
void error() {
try {
throw Exception('Test exception');
} catch (exception, stackTrace) {
codenicLogger.error(
messageLog.copyWith(details: 'error'),
data: {'foo': false, 'lorep': 'ipsum'},
error: exception,
stackTrace: stackTrace,
);
}
}
void wtf() {
try {
throw Exception('Test exception');
} catch (exception, stackTrace) {
codenicLogger.wtf(
messageLog.copyWith(details: 'What the f---'),
data: {'foo': false, 'lorep': 'ipsum'},
error: exception,
stackTrace: stackTrace,
);
}
}