The Custom Logger Library provides flexible logging functionalities for Dart applications, enabling customized console output with enhanced formatting and color-coded messages.
- Color Formatting: Customize log messages with various colors for improved readability.
- Log Level Configuration: Set different log levels and prefixes for information, errors, warnings, and successes.
- Customizable Output: Define total line lengths, characters for filling, dividers, and more for tailored log formatting.
Add the following line to your pubspec.yaml
:
dependencies:
custom_logger: ^1.0.0 # Replace with the latest version
Then, run:
$ flutter pub get
Import the library:
import 'package:custom_logger/custom_logger.dart';
Initialize the logger:
final logger = CustomLogger.instance;
Customize logging options:
CustomLogger.setInfoPrefixAndSuffix('ℹ️');
CustomLogger.setErrorPrefixAndSuffix('❌');
Use the logger:
CustomLogger.info('This is an information message');
CustomLogger.error('This is an error message');
CustomLogger.success('This is a success message');
CustomLogger.warning('This is a warning message');
The library provides several configuration options, including:
setInfoPrefixAndSuffix
setErrorPrefixAndSuffix
setSuccessPrefixAndSuffix
setWarningPrefixAndSuffix
setLineBreaksAfterLog
toggleCallerInfo
setInfoTitle
setErrorTitle
setSuccessTitle
setWarningTitle
- and more...
Check the API documentation for detailed information on available methods and their usage.
For more advanced usage and specific scenarios, refer to the examples provided in the /example
directory.
Please report any issues or provide feedback on the GitHub repository.
This project is licensed under the MIT License.