LogFormat enum

Output format for logs.

This enum defines the different output formats available for log messages in the Logar logging system. The format determines how log entries are displayed and structured.

Available Formats

  • pretty: Human-readable format for development and debugging
  • json: Structured format for production and external collectors

Format Selection

The format is typically selected based on the build mode:

  • Development: Pretty format for easy reading and debugging
  • Production: JSON format for structured logging and external tools

Usage Example

// Configure Logar with pretty format
Logar.configure(LogarConfig(
  format: LogFormat.pretty,
  minimumLevel: LogLevel.debug,
));

// Configure Logar with JSON format
Logar.configure(LogarConfig(
  format: LogFormat.json,
  minimumLevel: LogLevel.info,
));

// Set format dynamically
Logar.setFormat(LogFormat.json);

Format Examples

Pretty Format

[AMWAL_SDK] [14:30:25.123] [INFO] [PAYMENT] Payment processing started
[AMWAL_SDK] [14:30:26.456] [ERROR] [PAYMENT] Payment failed | Error: Invalid card

JSON Format

{
  "prefix": "AMWAL_SDK",
  "level": "INFO",
  "message": "Payment processing started",
  "timestamp": "2024-01-01T14:30:25.123Z",
  "tag": "PAYMENT"
}
Inheritance
Available extensions

Values

pretty → const LogFormat

Pretty printed format for development and debugging.

This format provides human-readable log output that is easy to read and understand during development. It includes:

  • Global prefix (if configured)
  • Timestamp (if enabled)
  • Log level
  • Tag (if provided)
  • Message
  • Additional data and error information

Use Cases

  • Development: Easy to read during development and debugging
  • Console Output: Human-friendly format for terminal/console display
  • Manual Review: Simple format for manual log analysis
  • Debugging: Clear, readable format for troubleshooting

Example Output

[AMWAL_SDK] [14:30:25.123] [INFO] [PAYMENT] Payment processing started
[AMWAL_SDK] [14:30:26.456] [ERROR] [PAYMENT] Payment failed | Error: Invalid card
[AMWAL_SDK] [14:30:27.789] [DEBUG] [API] API response received | Data: {"status": "success"}
json → const LogFormat

JSON format for production and external collectors.

This format provides structured, machine-readable log output that is ideal for production environments and external logging systems. It includes:

  • All log information in structured JSON format
  • Consistent data structure for parsing
  • Easy integration with log aggregation tools
  • Support for external log collectors

Use Cases

  • Production: Structured format for production logging
  • External Tools: Easy integration with log aggregation systems
  • Automated Analysis: Machine-readable format for automated processing
  • Monitoring: Structured data for monitoring and alerting systems

Example Output

{
  "prefix": "AMWAL_SDK",
  "level": "INFO",
  "message": "Payment processing started",
  "timestamp": "2024-01-01T14:30:25.123Z",
  "tag": "PAYMENT",
  "data": null,
  "error": null,
  "stackTrace": null
}

Properties

hashCode int
The hash code for this object.
no setterinherited
index int
A numeric identifier for the enumerated value.
no setterinherited
name String

Available on Enum, provided by the EnumName extension

The name of the enum value.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

values → const List<LogFormat>
A constant List of the values in this enum, in order of their declaration.