strategic_logger 0.1.12 strategic_logger: ^0.1.12 copied to clipboard
A strategic logger solution for many strategies like Crashlytics, Analytics, ConsoleLog and many as you want. One Call, Logs All.
Strategic Logger - One Call Logs All! #
Easy to use and extensible logger designed to support multiple logging strategies, like Firebase Crashlytics, Sentry, Firebase Analytics, and other that you want.
Show some ❤️ and star the repo to support the project
Features #
-
Multiple & Built-in Log Strategies: Firebase Crashlytics, Sentry, Firebase Analytics, ConsoleLog already implemented. (See examples tab)
-
Customizable: Extendable to include custom logging strategies depending on your application needs.
-
Easy to Use: Simple API for logging messages, errors, and fatal incidents across all integrated services.
-
Robust Error Handling: Includes predefined error types for handling common logging errors effectively.
Getting Started #
To get started with Strategic Logger, add it to your project as a dependency:
dependencies:strategic_logger: ^0.1.10
Initialization #
Initialize the logger once during the startup of your application:
import 'package:strategic\_logger/strategic\_logger.dart';
void main() {
logger.initialize(
level: LogLevel.info,
strategies: [
ConsoleLogStrategy(),
FirebaseAnalyticsLogStrategy(),
FirebaseCrashlyticsLogStrategy(),
],
);
}
Usage #
Logging messages is straightforward: (Easy and clean-code)
logger.log('This is an info log');
logger.error('This is an error message');
logger.fatal('This is a fatal error');
You can also log detailed events:
logger.log('User logged in', event: LogEvent(eventName: 'user\_login'));
Documentation #
For full documentation, including all configuration options and advanced usage examples, see examples tab.
Extending the Logger (Your Custom Strategy) #
To add a custom log strategy, extend the LogStrategy class:
class MyCustomLogStrategy extends LogStrategy {
@override
Future log({dynamic message, LogEvent? event}) async {
// Implement custom logging logic here
}
}
Register your custom strategy during logger initialization.
Contributing #
Contributions are welcome! Please read the contributing guide on our GitHub repository to get started.
License #
Strategic Logger is released under the MIT License.