codenic_logger 2.0.0-dev4 copy "codenic_logger: ^2.0.0-dev4" to clipboard
codenic_logger: ^2.0.0-dev4 copied to clipboard

A logger extension for providing structured and mutable log messages.

example/main.dart

import 'package:codenic_logger/codenic_logger.dart';

final codenicLogger = CodenicLogger();

void main() {
  // To run, type `dart --enable-asserts example/main.dart`.

  completeLogWithUserId();
  updateMessageLog();
  logError();
  logLevels();
}

void completeLogWithUserId() {
  final messageLog = MessageLog(
    id: 'complete_log_with_user_id',
    message: 'Log success',
    data: <String, dynamic>{'lorep': 'ipsum', 'mauris': 42},
  );

  // Assign then remove user ID after printing.

  codenicLogger
    ..userId = 'sample-uid'
    ..verbose(messageLog..message = 'Has user ID')
    ..userId = null;
}

void updateMessageLog() {
  final messageLog = MessageLog(id: 'update_message_log');

  codenicLogger.verbose(
    messageLog
      ..message = 'Update message log success'
      ..data.addAll(<String, dynamic>{'lorep': 'ipsum', 'mauris': 42}),
  );
}

void logError() {
  final messageLog = MessageLog(id: 'log_error');

  // throw Exception('Test exception');

  try {
    throw Exception('Test exception');
  } catch (exception, stackTrace) {
    codenicLogger.error(
      messageLog..message = 'An unknown error occurred',
      error: exception,
      stackTrace: stackTrace,
    );
  }
}

void logLevels() {
  final messageLog = MessageLog(id: 'log_levels');

  codenicLogger
    ..verbose(messageLog..message = 'Verbose log success')
    ..debug(messageLog..message = 'Debug log success')
    ..info(messageLog..message = 'Info log success')
    ..warn(messageLog..message = 'Warn log success')
    ..error(messageLog..message = 'Error log success')
    ..wtf(messageLog..message = 'Wtf log success');
}
6
likes
0
pub points
53%
popularity

Publisher

verified publishercodenic.dev

A logger extension for providing structured and mutable log messages.

Homepage
Repository (GitHub)
View/report issues

Documentation

Documentation

License

unknown (license)

Dependencies

equatable, logger, meta

More

Packages that depend on codenic_logger