Last updated:
0 purchases
nex common logs
nex_common_logs #
nex_common_logs is a Flutter package that provides a utility class for logging messages with different severity levels. It supports color formatting and various logging options to help you manage and display log messages efficiently.
Features #
Log messages with different severity levels: info, warning, error, success.
Customizable colors for log messages, file names, errors, and stack traces.
Option to enable or disable logging and filter messages by screen name.
Easy-to-use extension methods for quick logging.
Installation #
Add the following dependency to your pubspec.yaml file:
dependencies:
nex_common_logs: ^1.0.0
copied to clipboard
Run flutter pub get to install the package.
Usage #
Importing the Package #
import 'package:nex_common_logs/nex_common_logs.dart';
import '../logcolor/log_color.dart'; // Import your LogColors class if needed
copied to clipboard
Logging Messages #
You can log messages using the AppLogs class. Here's how to use each logging method:
Logging a Message
AppLogs.logMessage(
"This is a log message.",
name: "example.dart",
msgColor: LogColors.green,
textColor: LogColors.blue,
fileNameColor: LogColors.yellow,
);
copied to clipboard
Logging an Error
AppLogs.logError(
"This is additional information.",
name: "example.dart",
error: "An unexpected error occurred.",
stackTrace: StackTrace.current,
msgColor: LogColors.red,
textColor: LogColors.blue,
fileNameColor: LogColors.green,
errorColor: LogColors.yellow,
stackTraceColor: LogColors.cyan,
);
copied to clipboard
Logging a Warning
AppLogs.logWarning(
"This is a warning message.",
name: "example.dart",
error: "Warning occurred.",
stackTrace: StackTrace.current,
msgColor: LogColors.orange,
textColor: LogColors.blue,
fileNameColor: LogColors.green,
warningColor: LogColors.yellow,
stackTraceColor: LogColors.cyan,
);
copied to clipboard
Logging a Success
AppLogs.logSuccess(
text: "Operation completed successfully.",
name: "example.dart",
msgColor: LogColors.magenta,
textColor: LogColors.green,
fileNameColor: LogColors.blue,
);
copied to clipboard
Customizing Logging Behavior #
You can configure the logging behavior with the following options:
Enable/Disable Logging
AppLogs.settings(true); // Enable logging
AppLogs.settings(false); // Disable logging
copied to clipboard
Filter by Screen Name
AppLogs.screens = ['home', 'settings'];
copied to clipboard
Enable/Disable Print Handle
AppLogs.printHandle = true; // Disable logging
copied to clipboard
Extension Methods #
The package also includes extension methods for logging:
// For any object
void someMethod() {
this.logMessage(
text: "Logging from extension",
fileName: "example.dart",
);
}
copied to clipboard
Error Logging Extension
void someMethod() {
this.logError(
"Error occurred",
error: "Some error message",
stackTrace: StackTrace.current,
fileName: "example.dart",
);
}
copied to clipboard
Success Logging Extension
void someMethod() {
this.logSuccess(
text: "Operation successful",
fileName: "example.dart",
);
}
copied to clipboard
Warning Logging Extension
void someMethod() {
this.logWarning(
"Warning message",
error: "Warning details",
stackTrace: StackTrace.current,
fileName: "example.dart",
);
}
copied to clipboard
Contributing #
Contributions are welcome! Please create an issue or pull request on GitHub.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.