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
-
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.
To get started with Strategic Logger, add it to your project as a dependency:
dependencies:strategic_logger: ^0.1.10
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(),
],
);
}
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'));
For full documentation, including all configuration options and advanced usage examples, see examples tab.
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.
Contributions are welcome! Please read the contributing guide on our GitHub repository to get started.
Strategic Logger is released under the MIT License.