https://github.com/aiurovet/thin_logger
A minimal logger class, suitable mostly for console utilities rather than enterprise-grade applications.
https://github.com/aiurovet/thin_logger
dart logger minimal thin
Last synced: 2 months ago
JSON representation
A minimal logger class, suitable mostly for console utilities rather than enterprise-grade applications.
- Host: GitHub
- URL: https://github.com/aiurovet/thin_logger
- Owner: aiurovet
- License: mit
- Created: 2022-03-28T11:38:57.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-03-04T12:04:21.000Z (about 2 years ago)
- Last Synced: 2025-10-23T07:31:52.491Z (6 months ago)
- Topics: dart, logger, minimal, thin
- Language: Dart
- Homepage:
- Size: 8.79 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
A minimal logger class, suitable mostly for console utilities rather than enterprise-grade applications.
## Features
Comprises a single class that, by default, allows just three levels of the output: quiet (none), normal (data, errors and info) and verbose (maximum).
## Usage
The usage is pretty straightforward. Please see the sample code below or in the `example` folder of the GitHub repository.
```dart
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 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');
}
}
```