Skip to main content

Mojo struct

Level

struct Level

Represents logging severity levels.

Defines the available logging levels in ascending order of severity.

Implemented traits

AnyType, Comparable, Copyable, EqualityComparable, Identifiable, ImplicitlyCopyable, Movable, Stringable, UnknownDestructibility, Writable

Aliases

__copyinit__is_trivial

comptime __copyinit__is_trivial = True

__del__is_trivial

comptime __del__is_trivial = True

__moveinit__is_trivial

comptime __moveinit__is_trivial = True

CRITICAL

comptime CRITICAL = Level(60)

A serious error indicating that the program itself may be unable to continue running.

DEBUG

comptime DEBUG = Level(20)

Detailed information, typically of interest only when diagnosing problems.

ERROR

comptime ERROR = Level(50)

Due to a more serious problem, the software has not been able to perform some function.

INFO

comptime INFO = Level(30)

Confirmation that things are working as expected.

NOTSET

comptime NOTSET = Level(0)

Lowest level, used when no level is set.

TRACE

comptime TRACE = Level(10)

Repetitive trace information, Indicates repeated execution or IO-coupled activity, typically only of interest when diagnosing hangs or ensuring a section of code is executing.

WARNING

comptime WARNING = Level(40)

Indication that something unexpected happened, or may happen in the near future.

Methods

__lt__

__lt__(self, other: Self) -> Bool

Returns True if this level is less than the other level.

Args:

  • other (Self): The level to compare with.

Returns:

Bool: Bool: True if this level is less than the other level, False otherwise.

__eq__

__eq__(self, other: Self) -> Bool

Returns True if this level equals the other level.

Args:

  • other (Self): The level to compare with.

Returns:

Bool: Bool: True if the levels are equal, False otherwise.

__is__

__is__(self, other: Self) -> Bool

Returns True if this level is identical to the other level.

Args:

  • other (Self): The level to compare with.

Returns:

Bool: Bool: True if this level is identical to the other level, False otherwise.

color

color(self) -> Color

Returns the ANSI color of the level.

Returns:

Color: The corresponding Color of the level.

write_to

write_to(self, mut writer: T)

Writes the string representation of this level to a writer.

Args:

  • writer (T): The writer to write to.

__str__

__str__(self) -> String

Returns the string representation of this level.

Returns:

String: String: A human-readable string representation of the level (e.g., "DEBUG", "INFO").

__repr__

__repr__(self) -> String

Returns the detailed string representation of this level.

Returns:

String: String: A string representation including the type name and level value (e.g., "Level.DEBUG").

Was this page helpful?