thin_logger 0.1.2 copy "thin_logger: ^0.1.2" to clipboard
thin_logger: ^0.1.2 copied to clipboard

outdated

A minimal logger class, suitable mostly for console utilities rather than enterprise-grade applications.

example/thin_logger_example.dart

// Copyright (c) 2022, Alexander Iurovetski
// All rights reserved under MIT license (see LICENSE file)

import 'package:thin_logger/thin_logger.dart';

/// Return the logger level based on CLI option
///
int parseLevel(String optLevel) {
  switch (optLevel) {
    case '-q':
      return Logger.levelQuiet;
    case '-v':
      return Logger.levelVerbose;
    default:
      return Logger.levelDefault;
  }
}

/// The application entry point
///
void main(List<String> args) {
  // Initializing the logger object
  //
  var level = parseLevel(args.isEmpty ? '' : args[0]);
  var logger = Logger(level);

  // Printing various-level data
  //
  logger.out('Plain data');
  logger.error('ERR');
  logger.info('INF');

  // This is the most expensive call, as every string will be interpolated
  // (substituted with the values like 'abc $d ef ${g.h}') unconditionally,
  // and the respective Logger method will be called
  //
  if (logger.isVerbose) {
    logger.verbose('VRB');
  }
}
0
likes
0
pub points
0%
popularity

Publisher

verified publisheraiurovet.com

A minimal logger class, suitable mostly for console utilities rather than enterprise-grade applications.

Homepage

License

unknown (license)

More

Packages that depend on thin_logger