Skip to content

server.internal.logger

fn name_thread #

fn name_thread(name string)

name_thread labels the calling thread for every log line it writes from here on. Call it as the first statement of a spawned thread, paired with a deferred unname_thread: thread ids are reused once a thread exits, so a name left behind would be inherited by an unrelated thread later.

fn new #

fn new(min_level Level) &Logger

fn unname_thread #

fn unname_thread()

unname_thread drops the calling thread's registered name.

fn Level.from #

fn Level.from[W](input W) !Level

enum Level #

enum Level {
	debug = 0
	info  = 1
	warn  = 2
	error = 3
}

struct Logger #

@[heap]
struct Logger {
pub mut:
	min_level Level = .info
	prefix    string
	colored   bool = true
}

fn (Logger) with_prefix #

fn (l &Logger) with_prefix(prefix string) &Logger

fn (Logger) debug #

fn (l &Logger) debug(msg string)

fn (Logger) info #

fn (l &Logger) info(msg string)

fn (Logger) warn #

fn (l &Logger) warn(msg string)

fn (Logger) error #

fn (l &Logger) error(msg string)