NetworkLogger class
A singleton class for logging network-related information.
The NetworkLogger class is a wrapper around the Logger
package that provides
methods to log messages in different log levels (debug, info, warning, and error).
It ensures that logging is only done in debug mode to avoid cluttering production logs.
The logger uses the PrettyPrinter
to format logs and outputs them to the console.
This class is typically used for logging network requests and responses, but can be used for other types of logging during development.
Example usage:
NetworkLogger.shared.d("This is a debug message");
NetworkLogger.shared.i("This is an info message");
NetworkLogger.shared.w("This is a warning message");
NetworkLogger.shared.e("This is an error message");
Constructors
- NetworkLogger.new()
-
The factory constructor returns the singleton instance.
factory
Properties
- allowLog ↔ bool
-
A flag indicating whether logging is allowed.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- logger ↔ Logger
-
Logger instance that formats and prints logs.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
d(
dynamic value) → void - Logs a debug message.
-
e(
dynamic value) → void - Logs an error message.
-
i(
dynamic value) → void - Logs an info message.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
w(
dynamic value) → void - Logs a warning message.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
-
Singleton instance of NetworkLogger.
final