Link Search Menu Expand Document

Log

Table of contents

  1. Log
    1. Constants
    2. Log.print(string)
    3. Log.println(string)
    4. Log.fatal(string)
    5. Log.fatalln(string)
    6. Log.new(number)
    7. log.setPrefix(string)
    8. log.unsetPrefix(string)
    9. log.print(string)
    10. log.println(string)
    11. log.fatal(string)
    12. log.fatalln(string)

Log

To make use of the Log module an import is required.

import Log;

Constants

Constant Description
Log.stdout The default file descriptor where a process can write output.
Log.stderr The default file descriptor where a process can write error messages.
Log.stdin An input stream where data is sent to and read by a program.

Log.print(string)

Log.print("something extremely interesting"); // 2021/11/27 11:49:14 something extremely interesting

Log.println(string)

Log.println("hello, world! println"); // 2021/11/27 11:49:14 hello, world! print

Log.fatal(string)

Log the given output and exit the program with an exit code of 1.

Log.fatal("we've met a tragic end"); // 2021/11/27 11:49:14 we've met a tragic end

Log.fatalln(string)

Log the given output with a new line and exit the program with an exit code of 1.

Log.fatalln("hello, world! fatalln"); // 2021/11/27 11:49:14 hello, world! print

Log.new(number)

Create a new instance of a logger.

const log = Log.new(Log.stdout).unwrap();

log.setPrefix(string)

A prefix can be set on the logger that will be included in the output just before the user provided content.

log.setPrefix("prefix");

log.unsetPrefix(string)

Remove the prefix on the logger. This is a noop if there was no prefix previously set.

log.unsetPrefix();

log.print(string)

Log.print("something extremely interesting"); // 2021/11/27 11:49:14 something extremely interesting

log.println(string)

Log.println("hello, world! println"); // 2021/11/27 11:49:14 hello, world! print

log.fatal(string)

Log the given output and exit the program with an exit code of 1.

log.fatal("we've met a tragic end"); // 2021/11/27 11:49:14 we've met a tragic end

log.fatalln(string)

Log the given output with a new line and exit the program with an exit code of 1.

log.fatalln("hello, world! fatalln"); // 2021/11/27 11:49:14 hello, world! print

This site uses Just The Docs, with modifications.