A lightweight and efficient asynchronous logging library~~, outperform spdlog.~~
English | 简体中文
A lightweight and efficient C++ asynchronous logging library. It supports cross-platform (Windows/Linux), and mainly meets the common needs of project logging, such as log output, rolling, filtering, etc. The code is concise and easy to integrate with no redundant dependencies. It is compatible with C++26 standard and follows Apache License 2.0 open source agreement.
Real-practical C++ asynchronous logging library.
- 6 log levels, support dynamic filtering
- Console color output, file output without garbled characters
- Automatic log rolling by file size, no overwriting
- Asynchronous output, no blocking business logic
- Thread-safe, null pointer protection, no log loss
- Compatible with C++26 standard, adapting to the latest C++ features (refer to isocpp.org)
- Follows Apache License 2.0, supporting free use, reproduction and distribution with compliance
- Compiler Version: clang++ 22+, GCC lastest, MSVC lastest (must support C++23+)
- Operating System: Windows 10+ Linux Ubuntu 18.04+
This project only provide fishlogger.hpp header. Just include it in your code.
example:
clang++ -o test -Wall -std=c++26 -stdlib=libc++ -fexperimental-library -I./thirdparty/fmt -I./src your_code.cpp#include "fishlogger.hpp"
#include <iostream>
using namespace std;
using namespace FishLogger;
int main(int argc, char* argv[]) {
// Create logger object.
g_logger = make_unique<Logger>("a.log");;
// Option: output log to the console.
Logger::output_to_console = true;
// Option: Filter logs below verbose.
Logger::minimum_log_type = Logger::LogType::_VERBOSE_;
// Option: The maximum size of the file.
// If the threshold is exceeded, create a new file.
Logger::max_file_size_mb = 10; // 10 mb
// Option: Log keyword filtering switch.
// If the log content contains keywords, it will be ignored.
Logger::filter_keywords = {"apple", "banana", "orange"};
// tests
LOG_INFO("info test");
LOG_VERBOSE("verbose test");
LOG_ERROR("error test");
LOG_WARNING("warning test");
LOG_DEBUG("debug test");
LOG_FATAL("fatal test");
// also support format syntax
LOG_INFO("hello, {}", "world!");
LOG_VERBOSE("February has {} days", 28);
LOG_ERROR("{} is wonderful!", "FishLogger");
return 0;
}- Log Level Control: Set minimum log level to filter unnecessary logs
- Log Rolling: Modify
max_file_size_mbto adjust the rolling threshold (unit: MB) - Keyword Filtering: Add filter words to skip logs containing specific keywords
- Color Output: Console color is automatically matched by log level, file output filters color escape characters
Apache License 2.0 Detailed terms of the license: The library is distributed under the Apache License 2.0, which allows free use, reproduction, and distribution, with the requirement of retaining copyright notices and license information. For full license terms, please refer to the official Apache License 2.0 document.
Thanks for your reading 😊! If you like it, please give me a star🌟, your star is the driving force for my continuous development.