For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).
Logger
struct Logger[level: Level = DEFAULT_LEVEL]
A logger that outputs messages at or above a specified severity level.
Parameters
- level (
Level): The minimum severity level for messages to be logged.
Implemented traits
AnyType,
Copyable,
ImplicitlyCopyable,
ImplicitlyDeletable,
Movable
Methods
__init__
def __init__(out self, fd: FileDescriptor = stdout, *, prefix: String = "", source_location: Bool = False)
Initializes a new Logger.
Args:
- fd (
FileDescriptor): The file descriptor to write log messages to (defaults to stdout). - prefix (
String): The prefix to prepend to each log message (defaults to an empty string). - source_location (
Bool): Whether to include the source location in the log message (defaults to False).
trace
def trace[*Ts: Writable](self, *values: *Ts.values, *, sep: StringSlice[StaticConstantOrigin] = StringSlice(" "), end: StringSlice[StaticConstantOrigin] = StringSlice("\n"), location: Optional[SourceLocation] = None)
Logs a trace message.
Parameters:
- *Ts (
Writable): The types of values to log.
Args:
- *values (
*Ts.values): The values to log. - sep (
StringSlice[StaticConstantOrigin]): The separator to use between values (defaults to a space). - end (
StringSlice[StaticConstantOrigin]): The string to append to the end of the message (defaults to a newline). - location (
Optional[SourceLocation]): The location of the error (defaults tocall_location).
debug
def debug[*Ts: Writable](self, *values: *Ts.values, *, sep: StringSlice[StaticConstantOrigin] = StringSlice(" "), end: StringSlice[StaticConstantOrigin] = StringSlice("\n"), location: Optional[SourceLocation] = None)
Logs a debug message.
Parameters:
- *Ts (
Writable): The types of values to log.
Args:
- *values (
*Ts.values): The values to log. - sep (
StringSlice[StaticConstantOrigin]): The separator to use between values (defaults to a space). - end (
StringSlice[StaticConstantOrigin]): The string to append to the end of the message (defaults to a newline). - location (
Optional[SourceLocation]): The location of the error (defaults tocall_location).
info
def info[*Ts: Writable](self, *values: *Ts.values, *, sep: StringSlice[StaticConstantOrigin] = StringSlice(" "), end: StringSlice[StaticConstantOrigin] = StringSlice("\n"), location: Optional[SourceLocation] = None)
Logs an info message.
Parameters:
- *Ts (
Writable): The types of values to log.
Args:
- *values (
*Ts.values): The values to log. - sep (
StringSlice[StaticConstantOrigin]): The separator to use between values (defaults to a space). - end (
StringSlice[StaticConstantOrigin]): The string to append to the end of the message (defaults to a newline). - location (
Optional[SourceLocation]): The location of the error (defaults tocall_location).
warning
def warning[*Ts: Writable](self, *values: *Ts.values, *, sep: StringSlice[StaticConstantOrigin] = StringSlice(" "), end: StringSlice[StaticConstantOrigin] = StringSlice("\n"), location: Optional[SourceLocation] = None)
Logs a warning message.
Parameters:
- *Ts (
Writable): The types of values to log.
Args:
- *values (
*Ts.values): The values to log. - sep (
StringSlice[StaticConstantOrigin]): The separator to use between values (defaults to a space). - end (
StringSlice[StaticConstantOrigin]): The string to append to the end of the message (defaults to a newline). - location (
Optional[SourceLocation]): The location of the error (defaults tocall_location).
error
def error[*Ts: Writable](self, *values: *Ts.values, *, sep: StringSlice[StaticConstantOrigin] = StringSlice(" "), end: StringSlice[StaticConstantOrigin] = StringSlice("\n"), location: Optional[SourceLocation] = None)
Logs an error message.
Parameters:
- *Ts (
Writable): The types of values to log.
Args:
- *values (
*Ts.values): The values to log. - sep (
StringSlice[StaticConstantOrigin]): The separator to use between values (defaults to a space). - end (
StringSlice[StaticConstantOrigin]): The string to append to the end of the message (defaults to a newline). - location (
Optional[SourceLocation]): The location of the error (defaults tocall_location).
critical
def critical[*Ts: Writable](self, *values: *Ts.values, *, sep: StringSlice[StaticConstantOrigin] = StringSlice(" "), end: StringSlice[StaticConstantOrigin] = StringSlice("\n"), location: Optional[SourceLocation] = None)
Logs a critical message and aborts execution.
Parameters:
- *Ts (
Writable): The types of values to log.
Args:
- *values (
*Ts.values): The values to log. - sep (
StringSlice[StaticConstantOrigin]): The separator to use between values (defaults to a space). - end (
StringSlice[StaticConstantOrigin]): The string to append to the end of the message (defaults to a newline). - location (
Optional[SourceLocation]): The location of the error (defaults tocall_location).