Pyro

A dynamically-typed, garbage-collected scripting language.

Version 0.17.2

std::log



This library provides basic logging functionality. Logging levels, in increasing order of severity, are:

pub enum Level {
    Debug,
    Info,
    Warn,
    Error,
    Fatal,
}

Convenience functions are provided for unconditional logging to the standard output stream. Use a Logger instance to customize the logging-level and destination file.

Functions

debug(arg: any)
debug(format_string: str, *args: any)

A convenience function for writing a DEBUG message to the standard output stream.

  • Calling this function with a single argument is equivalent to calling $str() on that argument first and logging the resulting string.
  • Calling this function with more than one argument is equivalent to calling $fmt() on those arguments first and logging the resulting string.
error(arg: any)
error(format_string: str, *args: any)

A convenience function for writing an ERROR message to the standard output stream.

  • Calling this function with a single argument is equivalent to calling $str() on that argument first and logging the resulting string.
  • Calling this function with more than one argument is equivalent to calling $fmt() on those arguments first and logging the resulting string.
fatal(arg: any)
fatal(format_string: str, *args: any)

A convenience function for writing a FATAL message to the standard output stream.

Calling this function will write the log message, then cause the program to exit with a non-zero status code.

  • Calling this function with a single argument is equivalent to calling $str() on that argument first and logging the resulting string.
  • Calling this function with more than one argument is equivalent to calling $fmt() on those arguments first and logging the resulting string.
info(arg: any)
info(format_string: str, *args: any)

A convenience function for writing an INFO message to the standard output stream.

  • Calling this function with a single argument is equivalent to calling $str() on that argument first and logging the resulting string.
  • Calling this function with more than one argument is equivalent to calling $fmt() on those arguments first and logging the resulting string.
warn(arg: any)
warn(format_string: str, *args: any)

A convenience function for writing a WARN message to the standard output stream.

  • Calling this function with a single argument is equivalent to calling $str() on that argument first and logging the resulting string.
  • Calling this function with more than one argument is equivalent to calling $fmt() on those arguments first and logging the resulting string.

Classes

Logger() -> Logger

Returns a new Logger instance.

  • Messages will only be logged if their logging-level is greater than or equal to the logger's logging-level.
  • The logger's default logging-level is Level::Info.

Logger instances have the following public fields:

class Logger {
    # The logger's logging-level.
    # Defaults to Level::Info.
    pub var logging_level: Level;

    # The logger's output file.
    # Defaults to the standard output stream.
    pub var output_file: file;

    # Set to true to show microseconds in timestamps.
    # Defaults to false.
    pub var show_microseconds: bool;

    # Set to true to show milliseconds in timestamps.
    # Defaults to false.
    pub var show_milliseconds: bool;

    # Set to true to show UTC timestamps.
    # Defaults to false (i.e. shows local time).
    pub var show_utc: bool;
}

Logger instances have the following methods:

:debug(arg: any)
:debug(format_string: str, *args: any)

Writes a DEBUG message to the logger's output file.

  • Calling this method with a single argument is equivalent to calling $str() on that argument first and logging the resulting string.
  • Calling this method with more than one argument is equivalent to calling $fmt() on those arguments first and logging the resulting string.
:error(arg: any)
:error(format_string: str, *args: any)

Writes an ERROR message to the logger's output file.

  • Calling this method with a single argument is equivalent to calling $str() on that argument first and logging the resulting string.
  • Calling this method with more than one argument is equivalent to calling $fmt() on those arguments first and logging the resulting string.
:fatal(arg: any)
:fatal(format_string: str, *args: any)

Writes a FATAL message to the logger's output file.

Calling this method will write the log message, then cause the program to exit with a non-zero status code.

  • Calling this method with a single argument is equivalent to calling $str() on that argument first and logging the resulting string.
  • Calling this method with more than one argument is equivalent to calling $fmt() on those arguments first and logging the resulting string.
:info(arg: any)
:info(format_string: str, *args: any)

Writes an INFO message to the logger's output file.

  • Calling this method with a single argument is equivalent to calling $str() on that argument first and logging the resulting string.
  • Calling this method with more than one argument is equivalent to calling $fmt() on those arguments first and logging the resulting string.
:warn(arg: any)
:warn(format_string: str, *args: any)

Writes a WARN message to the logger's output file.

  • Calling this method with a single argument is equivalent to calling $str() on that argument first and logging the resulting string.
  • Calling this method with more than one argument is equivalent to calling $fmt() on those arguments first and logging the resulting string.