XU XUv0.16.0

#log/slog

import: #log/slog

counts: 2 functions, 9 methods, 1 types, 4 constants, 0 method sets

Structured logging. No package-level default logger. Text or one JSON object per line.

const LEVEL_DEBUG

XuAPI
pub const LEVEL_DEBUG = -4

Purpose

Constant LEVEL_DEBUG, defining protocol or algorithm parameters.

const LEVEL_INFO

XuAPI
pub const LEVEL_INFO = 0

Purpose

Constant LEVEL_INFO, defining protocol or algorithm parameters.

const LEVEL_WARN

XuAPI
pub const LEVEL_WARN = 4

Purpose

Constant LEVEL_WARN, defining protocol or algorithm parameters.

const LEVEL_ERROR

XuAPI
pub const LEVEL_ERROR = 8

Purpose

Constant LEVEL_ERROR, defining protocol or algorithm parameters.

struct Logger

XuAPI
pub struct Logger {
    pub min_level int
    pub add_source int
    pub add_time int
    pub use_stdout bool
}

Purpose

Structure encapsulating min_level, add_source, add_time, use_stdout.

Public fields

min_level int
field (int)
add_source int
field (int)
add_time int
field (int)
use_stdout bool
field (bool)

new_logger

XuAPI
pub fn new_logger() Logger

Purpose

Construct logger.

Parameters

No arguments are required.

Returns

Logger — a value of this type

new_json_logger

XuAPI
pub fn new_json_logger() Logger

Purpose

Construct json logger.

Parameters

No arguments are required.

Returns

Logger — a value of this type

($&Logger) set_level

XuAPI
pub fn (l $&Logger) set_level(level int)

Purpose

Operation on $&Logger: set level.

Parameters

l $&Logger
The Logger instance used by this call (exclusive borrow).
level int
level (int)

Returns

This call does not return a value.

(Logger) with

XuAPI
pub fn (l Logger) with(kvs <-> string) Logger

Purpose

Execute with on Logger.

Parameters

l Logger
The Logger instance used by this call (value receiver).
kvs <-> string
variadic string (seen inside the function as []string)

Returns

Logger — a value of this type

(Logger) with_group

XuAPI
pub fn (l Logger) with_group(name string) Logger

Purpose

Operation on Logger: derive a new value with group.

Parameters

l Logger
The Logger instance used by this call (value receiver).
name string
name (string)

Returns

Logger — a value of this type

(&Logger) enabled

XuAPI
pub fn (l &Logger) enabled(level int) bool

Purpose

Execute enabled on &Logger.

Parameters

l &Logger
The Logger instance used by this call (borrow).
level int
level (int)

Returns

bool — true or false

(&Logger) log

XuAPI
pub fn (l &Logger) log(level int, msg string)

Purpose

Operation on &Logger: natural logarithm.

Parameters

l &Logger
The Logger instance used by this call (borrow).
level int
level (int)
msg string
message (string)

Returns

This call does not return a value.

(&Logger) debug

XuAPI
pub fn (l &Logger) debug(msg string, kvs <-> string)

Purpose

Execute debug on &Logger.

Parameters

l &Logger
The Logger instance used by this call (borrow).
msg string
message (string)
kvs <-> string
variadic string (seen inside the function as []string)

Returns

This call does not return a value.

(&Logger) info

XuAPI
pub fn (l &Logger) info(msg string, kvs <-> string)

Purpose

Execute info on &Logger.

Parameters

l &Logger
The Logger instance used by this call (borrow).
msg string
message (string)
kvs <-> string
variadic string (seen inside the function as []string)

Returns

This call does not return a value.

(&Logger) warn

XuAPI
pub fn (l &Logger) warn(msg string, kvs <-> string)

Purpose

Execute warn on &Logger.

Parameters

l &Logger
The Logger instance used by this call (borrow).
msg string
message (string)
kvs <-> string
variadic string (seen inside the function as []string)

Returns

This call does not return a value.

(&Logger) error

XuAPI
pub fn (l &Logger) error(msg string, kvs <-> string)

Purpose

Execute error on &Logger.

Parameters

l &Logger
The Logger instance used by this call (borrow).
msg string
message (string)
kvs <-> string
variadic string (seen inside the function as []string)

Returns

This call does not return a value.