A revised version of NanoLog which writes human readable log file, and is easier to use.

Overview

NanoLogLite

NanoLogLite is a revised version of NanoLog, and is easier to use without performance compromise.

The major changes are:

  • NanoLogLite writes directly in human readable format instead of writing to a binary file and needing an additional decoder for reading, this behaves like other log libraries.
  • User can now register a log msg callback function. This is useful in circumstances where warning/error msgs need to be published out for alerting.
  • NanoLogLite won't create a default log file before user calling NanoLog::setLogFile.
  • Log msg header is improved: NanoLogLite by default sets a meaningful thread id, and also allows user to customize the thread name; Time string is shortened, and folder part is removed from the file path.
  • NanoLogLite won't create background thread internally, it requires user to poll it periodically. The idea is that user should have the ability to manage the threads in their program. This would not make it harder to use as the user can simply create a thread himself to poll if he doesn't care.
  • Some shortcut macros are added for easier writing logging code: logd, logi, logw, loge for logging DEBUG/INFO/WARNING/ERROR msgs respectively.
  • Log timestamp precision is much improved, it's almost synchronized with system time.
  • Performance is improve a little as the Stagging buffer is re-implemented.

Examples of the new features:

// easier to write log msg
logi("Simple log message with 1 parameters, %d", i);

// set a meaningful name for current thread
NanoLog::setThreadName("main"); 

// set a callback/hook to capture msgs with WARNING or above log level
void logcb(uint64_t ns, NanoLog::LogLevel level, const char* msg, size_t msg_len) {
  printf("logcb, ns: %ld, msg: %s\n", ns, msg);
}

// we can set a minimum callback interval(in seconds) for each msg, 0 here means no such limitation
NanoLog::setLogCB(logcb, NanoLog::WARNING, 0);

// user need to poll it
NanoLog::poll(); 

image

Test

Check log_test.cc for example usage.

How to build static library

Simply delete SHARED in CMakeLists.txt.

You might also like...
Single header C++ logging library. It is extremely powerful, extendable, light-weight, fast performing, thread and type safe and consists of many built-in features. It provides ability to write logs in your own customized format. It also provide support for logging your classes, third-party libraries, STL and third-party containers etc. Single header C++ logging library. It is extremely powerful, extendable, light-weight, fast performing, thread and type safe and consists of many built-in features. It provides ability to write logs in your own customized format. It also provide support for logging your classes, third-party libraries, STL and third-party containers etc. Colorful Logging is a simple and efficient library allowing for  logging and benchmarking.
Colorful Logging is a simple and efficient library allowing for logging and benchmarking.

Colorful-Logging "Colorful Logging" is a library allowing for simple and efficient logging as well for benchmarking. What can you use it for? -Obvious

Portable, simple and extensible C++ logging library
Portable, simple and extensible C++ logging library

Plog - portable, simple and extensible C++ logging library Pretty powerful logging library in about 1000 lines of code Introduction Hello log! Feature

A DC power monitor and data logger
A DC power monitor and data logger

Hoverboard Power Monitor I wanted to gain a better understanding of the power consumption of my hoverboard during different riding situations. For tha

An ATTiny85 implementation of the well known sleep aid. Includes circuit, software and 3d printed case design
An ATTiny85 implementation of the well known sleep aid. Includes circuit, software and 3d printed case design

dodowDIY An ATTiny85 implementation of the well known sleep aid. Includes circuit, software and 3d printed case design The STL shells are desiged arou

A BSD-based OS project that aims to provide an experience like and some compatibility with macOS
A BSD-based OS project that aims to provide an experience like and some compatibility with macOS

What is Helium? Helium is a new open source OS project that aims to provide a similar experience and some compatibiilty with macOS on x86-64 sytems. I

Netdata's distributed, real-time monitoring Agent collects thousands of metrics from systems, hardware, containers, and applications with zero configuration.
Netdata's distributed, real-time monitoring Agent collects thousands of metrics from systems, hardware, containers, and applications with zero configuration.

Netdata is high-fidelity infrastructure monitoring and troubleshooting. It runs permanently on all your physical/virtual servers, containers, cloud deployments, and edge/IoT devices, and is perfectly safe to install on your systems mid-incident without any preparation.

Receive and process logs from the Linux kernel.

Netconsd: The Netconsole Daemon This is a daemon for receiving and processing logs from the Linux Kernel, as emitted over a network by the kernel's ne

Owner
Meng Rao
Meng Rao
Mini-async-log-c - Mini async log C port. Now with C++ wrappers.

Description A C11/C++11 low-latency wait-free producer (when using Thread Local Storage) asynchronous textual data logger with type-safe strings. Base

null 69 Nov 9, 2022
log4cplus is a simple to use C++ logging API providing thread-safe, flexible, and arbitrarily granular control over log management and configuration. It is modelled after the Java log4j API.

% log4cplus README Short Description log4cplus is a simple to use C++17 logging API providing thread--safe, flexible, and arbitrarily granular control

null 1.4k Jan 4, 2023
View and log aoe-api requests and responses

aoe4_socketspy View and log aoe-api requests and responses Part 1: https://www.codereversing.com/blog/archives/420 Part 2: https://www.codereversing.c

Alex Abramov 10 Nov 1, 2022
Compressed Log Processor (CLP) is a free tool capable of compressing text logs and searching the compressed logs without decompression.

CLP Compressed Log Processor (CLP) is a tool capable of losslessly compressing text logs and searching the compressed logs without decompression. To l

null 516 Dec 30, 2022
Example program using eBPF to log data being based in using shell pipes

Example program using eBPF to log data being based in using shell pipes (|)

pat_h/to/file 35 Oct 21, 2022
Log engine for c plus plus

PTCLogs library PTCLogs is a library for pretty and configurable logs. Installation To install the library (headers and .so file), clone this repo and

Pedro Tavares de Carvalho 12 May 20, 2022
Cute Log is a C++ Library that competes to be a unique logging tool.

Cute Log Cute Log is a C++ Library that competes to be a unique logging tool. Version: 2 Installation Click "Code" on the main repo page (This one.).

null 3 Oct 13, 2022
Sagan - a multi-threads, high performance log analysis engine

Sagan - Sagan is a multi-threads, high performance log analysis engine. At it's core, Sagan similar to Suricata/Snort but with logs rather than network packets.

Quadrant Information Security 80 Dec 22, 2022
A single file, public domain C implementation of aSchroeder reverb.

Introduction This is a reverb implementation based on Freeverb, a public domain reverb written by Jezar at Dreampoint in 2000. The library is written

Philip Bennefall 55 Nov 27, 2022