Skip to content

A strategic logger solution for many strategies like Crashlytics, Analytics, ConsoleLog and many as you want.

License

Notifications You must be signed in to change notification settings

sauloroncon/strategic_logger

Repository files navigation

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. Buy Me A Coffee

License

Strategic Logger is released under the MIT License.

About

A strategic logger solution for many strategies like Crashlytics, Analytics, ConsoleLog and many as you want.

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages