Crates.io | tarolog |
lib.rs | tarolog |
version | 0.2.0 |
source | src |
created_at | 2024-01-18 10:45:31.581419 |
updated_at | 2024-11-02 15:06:45.801748 |
description | Library for flexible configuration of tarantool logs |
homepage | |
repository | https://git.picodata.io/picodata/picodata/tarolog |
max_upload_size | |
id | 1104075 |
size | 56,284 |
Library for flexible configuration of tarantool logs. Allows you to set your own log format or choose from builtin formats. Supports "data injectors" for enrichment log records with any data (e.g. instance-id or request-id). All formats are applying to tarantool internal logs as well.
serde
library for a log record generation.Also, you can implement your own format.
generate file size (lines per sec) bigger is better |
generated stdout output (mb per sec) bigger is better |
|
---|---|---|
tarantool-json | 144135 | 49,675 |
tarolog-json | 203785 | 82 |
tarolog-json-serde | 188217 | 70,25 |
tarantool-plain | 210876 | 29,475 |
tarolog-plain | 231691 | 29,95 |
See a "bench" package for familiarize with benchmark process.
In this example we use json format with injectors that propagate two fields:
use tarolog;
use tarolog::Format;
use tarantool;
use tarantool::ffi;
use std::collections::HashMap;
use log::info;
fn main() {
tarolog::set_default_logger_format(Format::Json(Some(|| {
let mut additional_info =
HashMap::from([("additional data".to_string(), serde_json::Value::Bool(true))]);
// lua available only in tx thread, check it
let cord_is_main = unsafe { ffi::tarantool::cord_is_main() };
if cord_is_main {
let lua = tarantool::lua_state();
if let Ok(Some(rid)) = lua.eval("return require('fiber').self().storage['rid']") {
additional_info.insert("request_id".to_string(), serde_json::Value::String(rid));
}
}
additional_info
})));
info!("now new format is installed");
}
tarantool-test is required.
cargo test
cargo build; tarantool-test -p ./target/debug/libtests.so -- -i tests/test_init.lua
make test