LogMessage class
Represents a log message with associated metadata.
A LogMessage encapsulates the details of a log entry, including its message, level, category, environment, and timestamp. It provides methods to format the message in various ways (e.g., JSON, CSV, or string).
Example:
var logMsg = LogMessage(message: "App started", category: "App", level: LogLevel.info);
print(logMsg.toString());
- Implementers
Constructors
- LogMessage({required String message, LogLevel level = LogLevel.none, String environment = '', String category = ''})
- Creates a new LogMessage instance.
Properties
- category ↔ String
-
The category of the log (e.g., "App", "Network").
getter/setter pair
- environment ↔ String
-
The environment context for the log (e.g., "prod", "dev").
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- isCritical ↔ bool
-
getter/setter pair
- isDated ↔ bool
-
Indicates whether the message has been formatted with a timestamp.
getter/setter pair
- level ↔ LogLevel
-
The severity level of the log message.
getter/setter pair
- message ↔ String
-
The content of the log message.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- serviceTag ↔ Object?
-
getter/setter pair
- timeLine ↔ int
-
The timeline identifier for the log message.
getter/setter pair
- timeStamp ↔ DateTime?
-
The timestamp when the log message was created.
getter/setter pair
Methods
-
clone(
) → LogMessage - Creates a deep copy of the LogMessage.
-
getCSVString(
) → String - Converts the log message to a CSV row string.
-
getJsonString(
bool first) → String - Converts the log message to a JSON string.
-
getStringMessageForLogger(
bool withCategory, bool envActive, bool withTimeLine) → String - Formats the log message as a human-readable string for logging.
-
getTimeStampedFormated(
) → String - Formats the timestamp in a readable format.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setCritical(
) → dynamic - indicate message comes from CriticalMode
-
toString(
) → String -
Returns a string representation of the log message with timestamp.
override
-
toStringWOTimeStamp(
) → String - Returns a string representation of the log message without timestamp.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
fromString(
String category, String message, {String? environment, Object level = 'info'}) → LogMessage - Creates a LogMessage from string parameters.
-
getCSVHeader(
) → String - Provides the CSV header for log messages.