any_logger library
A powerful, flexible, and intuitive logging library for Dart and Flutter applications.
This library provides a comprehensive logging solution with:
- Zero configuration quick start
- Progressive complexity from simple to enterprise
- Automatic device/session tracking
- Multiple appender types (console, file, and extensible)
- Performance optimizations with early exits and lazy evaluation
Quick Start
import 'package:any_logger/any_logger.dart';
void main() {
Logger.info("I'm logging!"); // Auto-configures on first use
}
Using the Mixin
class MyService with AnyLogger {
@override
String get loggerName => 'MyService';
void doWork() {
logInfo('Starting work');
logDebug('Debug details');
}
}
Classes
- Appender
- AppenderBuilder
- A builder class for programmatically creating and configuring Appender instances.
- AppenderRegistry
- A central registry for creating Appender instances from configuration. Extension packages can register their own appender types here.
- ConsoleAppender
- ConsoleAppenderBuilder
- DateFormatCache
- Helper class to cache date formatters
- FileAppender
- FileAppenderBuilder
- FileIdProvider
- FileInfo
- IdGenerator
- Simple ID generator without crypto dependency
- IdProvider
- Abstract interface for managing device and session identification
- IdProviderResolver
- Logger
- Main Logger class with both static and instance methods
- LoggerBuilder
- LoggerConfig
- A configuration class to hold a list of appenders and a root logging level.
- LoggerFactory
- Factory for creating and managing loggers
- LoggerPresets
- Preset configurations for common use cases with device and session tracking
- LoggerStackTrace
- LogRecord
- LogRecordFormatter
- Optimized formatter with MDC pattern caching (no intl dependency)
- MemoryIdProvider
- In-memory ID provider that doesn't persist IDs Perfect for:
- NullIdProvider
- Null ID provider that returns null for all IDs Used as default when no IDs are needed
- SimpleDateFormat
- Simple date formatter that doesn't require the intl package Supports common date format patterns used in logging
- Utils
Enums
- ConsoleLoggerMode
- Level
- RotationCycle
- Enhanced rotation cycle with sub-day intervals
Mixins
- AnyLogger
- A mixin that provides comprehensive logging capabilities to any Dart class.
Extensions
- DateTimeFormatting on DateTime
- Extension method for convenient date formatting
Constants
- kClose → const String
- kDefaultDateFormat → const String
- kOpen → const String
- kStackDepthOffset → const int
- kStackDepthOfThis → const int
Functions
-
consoleAppenderBuilder(
) → ConsoleAppenderBuilder - A specialized builder for creating and configuring ConsoleAppender instances.
-
fileAppenderBuilder(
String filePattern) → FileAppenderBuilder - A specialized builder for creating and configuring FileAppender instances.
Typedefs
-
AppenderFactoryFunction
= Future<
Appender> Function(Map<String, dynamic> config, {DateTime? date, bool test}) - HttpCompleteCallback = void Function()