https://github.com/ibob/jalog
Just Another Logging library for C++
https://github.com/ibob/jalog
Last synced: 9 months ago
JSON representation
Just Another Logging library for C++
- Host: GitHub
- URL: https://github.com/ibob/jalog
- Owner: iboB
- License: mit
- Created: 2021-11-04T08:32:07.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-10-29T08:48:57.000Z (over 1 year ago)
- Last Synced: 2025-01-01T01:50:23.884Z (over 1 year ago)
- Language: C++
- Size: 203 KB
- Stars: 8
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Jalog
[](https://isocpp.org/) [](https://en.wikipedia.org/wiki/C%2B%2B#Standardization) [](https://opensource.org/licenses/MIT) [](https://github.com/iboB/jalog/actions/workflows/build.yml)
Just Another Logging library for C++17.
## Features
* Synchronous and asynchronous logging
* Five fixed log levels: Debug, Info, Warning, Error, Critical
* Custom log scopes (categories).
* Custom log sinks and some predefined ones.
* Allows multiple independent loggers
* Thread safe
* Optimized for (in that order):
* Performance
* Ease of use
* Compilation time
* Logging styles:
* Jalog-style: `log("This is Jalog: ", 12, " and ", 3.141592);`
* `std::ostream`-like: `log << "This and " << 42;`
* `printf`-like: `log("Crushing it since %d", 1971);`
* raw (which allows you to provide your own style, say `std::format`)
## Example
A small snippet showcasing some of the library's features:
*It also exists as a complete and buildable example [here](example/e-BasicShowcase.cpp).*
```c++
JALOG(Debug, "Log integers: ", 34, ", or in a custom base: ", jalog::base<16>(255));
JALOG(Info, "Log floating point numbers with no precision loss: ", 12.4356631);
std::string str = "my string";
std::string_view sv = std::string_view(str).substr(0, 6);
JALOG(Warning, "Log strings: '", str, "' and string views '", sv, "'");
Person alice = {"Alice", 34};
JALOG(Error, "Log types with custom ostream output: ", alice);
JALOG_PRINTF(Critical, "Log printf style: %d, %.3f, %s", 43, 3.14159, str.c_str());
```
This will produce an output similar to this:

## Documentation
* [Features and Glossary](doc/features.md)
* [Adding Jalog to your project](doc/how-to-add.md)
* [The Basics](doc/basics.md)
* [Asynchronous Logging](doc/async.md)
* [Creating Scopes](doc/creating-scopes.md)
* [Logging: Macros, Styles, Custom Types](doc/logging.md)
* [Custom Sinks](doc/custom-sinks.md)
* Advanced topics:
* [Using Multiple Loggers](doc/multiple-loggers.md)
* [Inheriting from Scope](doc/inherit-scope.md)
* [Development and Implementation Notes](doc/dev.md)
## Building and Usage
There is an accompanying `CMakeLists.txt` file in the repo. Use CMake to generate project or make files for your desired platform and compiler.
The library uses [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake) to manage its dependencies and the best way to use it is as a CPM.cmake pacakge.
See [Adding Jalog to your project](doc/how-to-add.md) for more info.
## Contributing
Issues and pull requests are welcome.
See [Development and Implementation Notes](doc/dev.md) on how to work on Jalog.
## License
This software is distributed under the MIT Software License.
See accompanying file LICENSE or copy [here](https://opensource.org/licenses/MIT).
Copyright © 2021-2025 [Borislav Stanimirov](http://github.com/iboB)