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 run make install.

git clone http://github.com/ptcar2009/ptclogs
cd ptclogs
make install

Usage

To compile the library, you need to link the library in compilation.

gcc -o main main.cpp -lptclogs

Log level configuration

Log level can either be set via a parameter on instantiation or by a environment variable.

If set by an environment variable, you need to set the VERBOSITY environment variable to a number between 0 and 5, being 0 the lowes verbosity with only fatal logs and 5 the highest, containing debug logs.

If set by instantiation, it's a parameter in the Logger class.

Console Logger

Console logger is for easily readable console logs with configurable log level sensitivity.

Example

#include <ptclogs/driver/console_driver.hpp>
#include <ptclogs/logs.hpp>

#include <string>

using namespace logger;
using logger::Field;
using std::string;
int main() {
   auto logger = Logger<ConsoleDriver>();
   logger.INFO("this is a message in info level", Field<int>("number", 12),
               Field<string>("string", "hello I am string"));

   logger.DEBUG("this is a message in debug level", Field<int>("error", 12));
   logger.ERROR("this is a message in error level");
}

info console

debug console

JSON logger

JSON logger encodes all information in machine readable JSON formatted objects.

Example

#include <ptclogs/driver/json_driver.hpp>
#include <ptclogs/logs.hpp>

#include <string>

using namespace logger;
using logger::Field;
using std::string;
int main() {
    auto logger = Logger<JSONDriver>();
    logger.INFO("this is a message in info level", Field<int>("number", 12),
		Field<string>("string", "hello I am string"));

    logger.DEBUG("this is a message in debug level", Field<int>("error", 12));
    logger.ERROR("this is a message in error level");
}

info json info json jq debug json jq

Owner
Pedro Tavares de Carvalho
Avid programmer and project starter. Always loved and still love learning new skills and making something that I can look at and be proud of.
Pedro Tavares de Carvalho
Similar Resources

Simple application log library. supporting multiple log levels, custom output & flash memory support.

Simple application log library. supporting multiple log levels, custom output  & flash memory support.

ArduinoLog - C++ Log library for Arduino devices An minimalistic Logging framework for Arduino-compatible embedded systems. ArduinoLog is a minimalist

Nov 12, 2022

This is a C plus plus coding template for Compitative programming. This template is very optimized for the Online Judgment

C-plusplus-compitative-Programming-Template Tech We Used C++ Features Easy to compile Easy debug facility Analysised and optimized base template Steps

Jan 27, 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.

Dec 22, 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

Jan 4, 2023

Is a linear data structure with O(log n) searches and O(cbrt n) insertions and index lookups.

Is a linear data structure with O(log n) searches and O(cbrt n) insertions and index lookups.

A binary cube is a linear data structure that contains a sorted two dimensional dynamic array of nodes which each point to a sorted array

Jul 13, 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 (|)

Oct 21, 2022

Parses existing Chia plotter log files and builds a .csv file containing all the important details

Chia Log Analysis Parses through Chia plotter log files and plops all the juicy details into a CSV file! Build See below for instructions if you prefe

May 10, 2022

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

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

NanoLogLite NanoLogLite is a revised version of NanoLog, and is easier to use without performance compromise. The major changes are: NanoLogLite write

Nov 22, 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.).

Oct 13, 2022

A proxy service of incremental log of OceanBase

OceanBase Migration Serivce LogProxy OceanBase增量日志代理服务,是 OMS 的一部分。基于 liboblog, 以服务的形式,提供实时增量链路接入和管理能力,方便应用接入OceanBase增量日志;能够解决网络隔离的情况下,订阅增量日志的需求;并提供多种

Nov 25, 2022

IntX is a C++11 port of IntX arbitrary precision Integer library with speed, about O(N * log N) multiplication/division algorithms implementation.

IntX IntX is a C++11 port of IntX arbitrary precision Integer library with speed, about O(N * log N) multiplication/division algorithms implementation

Dec 22, 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

Dec 30, 2022

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

Nov 1, 2022

PRINT++ is a simple, open source print library for C++, the main usage of PRINT++ is printing out "log" messages

PRINT++ is a simple, open source print library for C++, the main usage of PRINT++ is printing out

note that for now, print++ is using std::cout. In future it will be using own print function. Windows version can be unstable That library is in alpha

Jan 23, 2022

android analysis tools, jni trace by native hook, libc hook, write log with caller's addr in file or AndroidLog

编译方法 unix like mkdir "build" cd build cmake .. -DNDK=your_ndk_path/Android/sdk/ndk/22.0.7026061 -DANDROID_ABI=armeabi-v7a make -j8 或者使用andriod studio编

Dec 1, 2022

LibU is a multiplatform utility library written in C, with APIs for handling memory allocation, networking and URI parsing, string manipulation, debugging, and logging in a very compact way, plus many other miscellaneous tasks

== MaKL is a Prerequisite == LibU needs http://koanlogic.com/makl to configure and build. The following commands should be sufficient to get MaKL i

Dec 25, 2022

Header-only C++11 library to encode/decode base64, base64url, base32, base32hex and hex (a.k.a. base16) as specified in RFC 4648, plus Crockford's base32. MIT licensed with consistent, flexible API.

cppcodec Header-only C++11 library to encode/decode base64, base64url, base32, base32hex and hex (a.k.a. base16) as specified in RFC 4648, plus Crockf

Dec 28, 2022

Pacman written in C++ using Allegro 5, plus Dijkstra path finder

Pacman Pacman written in C++ using Allegro 5, plus Dijkstra path finder See the interface through the Pacman image Setup Dependencies sudo apt install

May 23, 2022

Header-only C++11 library to encode/decode base64, base64url, base32, base32hex and hex (a.k.a. base16) as specified in RFC 4648, plus Crockford's base32. MIT licensed with consistent, flexible API.

cppcodec Header-only C++11 library to encode/decode base64, base64url, base32, base32hex and hex (a.k.a. base16) as specified in RFC 4648, plus Crockf

Dec 28, 2022
Related tags
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

Nov 9, 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.

Dec 22, 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

Jan 4, 2023
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 (|)

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

NanoLogLite NanoLogLite is a revised version of NanoLog, and is easier to use without performance compromise. The major changes are: NanoLogLite write

Nov 22, 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.).

Oct 13, 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

Dec 30, 2022
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

Nov 1, 2022
Log engine for c plus plus
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

May 20, 2022
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

Nov 9, 2022