service-logging

Crates.ioservice-logging
lib.rsservice-logging
version0.4.7
sourcesrc
created_at2020-12-02 23:42:42.267372
updated_at2021-02-16 20:46:50.060469
descriptionAsynchronous structured logging in tiny library (6KB) with clients for Coralogix and console.log. WASM compatible
homepagehttps://github.com/stevelr/service-logging
repositoryhttps://github.com/stevelr/service-logging
max_upload_size
id319066
size32,356
(stevelr)

documentation

https://docs.rs/service-logging

README

Asynchronous structured logging in tiny library (6KB) with clients for Coralogix and console.log. WASM compatible.

Usage

Use the log! macro to log key-value pairs, which are json-encoded before sending to logging service

use service_logging::{log, LogQueue, Severity::{Info,Error}};
let logger =  CoralogixLogger::init(CoralogixConfig{
    api_key: "0000",
    application_name: "MyApp",
    endpoint: "https://api.coralogix.com/api/v1/logs"});
let mut lq = LogQueue::default();

log!(lq, Info, 
  method: "GET",
  url: url,
  status: 200
);

log!(lq, Error,
  user: user,
  message: "Too many failed login attempts",
  attempts: count
);

logger.send("http", lq.take()).await?;
Commit count: 29

cargo fmt