pine
Types
Logger
opaque
pub opaque type Logger
Functions
pub fn debug(logger: Logger, msg: String) -> Logger
pub fn err(logger: Logger, msg: String) -> Logger
pub fn format_json(logger: Logger) -> Logger
pub fn format_plain(logger: Logger) -> Logger
pub fn info(logger: Logger, msg: String) -> Logger
pub fn level_debug(logger: Logger) -> Logger
pub fn level_err(logger: Logger) -> Logger
pub fn level_info(logger: Logger) -> Logger
pub fn level_warn(logger: Logger) -> Logger
pub fn new() -> Logger
pub fn set_format(
logger: Logger,
new_format: fn(Log) -> String,
) -> Logger
pub fn set_level(logger: Logger, new_level: Level) -> Logger
pub fn set_transport(
logger: Logger,
new_transport: fn(String) -> Nil,
) -> Logger
pub fn transport_console(logger: Logger) -> Logger
pub fn transport_file(logger: Logger, filename: String) -> Logger
pub fn warn(logger: Logger, msg: String) -> Logger
pub fn with_bool(
logger: Logger,
key: String,
value: Bool,
) -> Logger
Adds a new ‘bool’ attribute to a logger.
import pine
pub fn main() {
let logger =
pine.new()
|> pine.json()
|> pine.bool("is_admin", True)
pine.info(logger, "hello world!")
// {"level": "info", "msg": "hello world!", "is_admin": True}
}
pub fn with_float(
logger: Logger,
key: String,
value: Float,
) -> Logger
Adds a new ‘float’ attribute to a logger.
import pine
pub fn main() {
let logger =
pine.new()
|> pine.json()
|> pine.int("threshold", 0.43)
pine.info(logger, "hello world!")
// {"level": "info", "msg": "hello world!", "threshold": 0.43}
}
pub fn with_int(
logger: Logger,
key: String,
value: Int,
) -> Logger
Adds a new ‘int’ attribute to a logger.
import pine
pub fn main() {
let logger =
pine.new()
|> pine.json()
|> pine.int("version", 1)
pine.info(logger, "hello world!")
// {"level": "info", "msg": "hello world!", "version": 1}
}
pub fn with_string(
logger: Logger,
key: String,
value: String,
) -> Logger
Adds a new ‘string’ attribute to a logger.
import pine
pub fn main() {
let logger =
pine.new()
|> pine.json()
|> pine.string("environment", "dev")
pine.info(logger, "hello world!")
// {"level": "info", "msg": "hello world!", "environment": "dev"}
}