Single-header (STB-style), lightweight C logger (CC0)
  • C 89.6%
  • Makefile 6.1%
  • C++ 4.3%
Find a file
2026-09-12 22:36:56 +02:00
test v6: Timestamping 2026-09-12 19:45:15 +02:00
.gitignore v6: Timestamping 2026-09-12 19:45:15 +02:00
example.c v6: Timestamping 2026-09-12 19:45:15 +02:00
LICENSE v1: Logging. 2026-09-10 11:06:50 +02:00
Makefile v2: Features. 2026-09-10 22:30:14 +02:00
Readme.md v2: Features. 2026-09-10 22:30:14 +02:00
solog.h v7: Bugfixes 2026-09-12 22:36:56 +02:00

SoLog

Some Ordinary Logging / Solar's Logger

A lightweight, single-header (STB-style) C/C++ logging library.

All you need is solog.h -- all the rest is either advertising (this Readme) or test code.

Features

  • Header-only (stb-style): No build configuration or compilation steps.
  • Atomic output: Single vfprintf() call per log entry.
  • Short-circuiting: Arguments are not evaluated if log level not met.
  • Configurable at runtime: Adjust minimum log level and destination stream on the fly.
  • C & C++ compatible: Works cleanly with standard C99/C11 and C++11+.
  • SOLOG_H versioning: Include guard SOLOG_H defined to version number
  • Warning-free: Even at strictest warning settings. A few false-positive warnings suppressed.

Usage

In every source file needing logging:

#include "solog.h"

In exactly one translation unit, define SOLOG_IMPLEMENTATION before including:

#define SOLOG_IMPLEMENTATION
#include "solog.h"

int main(void) {
    /* Optional runtime configuration */
    solog_config.level  = SOLOG_LVL_DEBUG; /* Default: SOLOG_LVL_INFO */
    solog_config.stream = stdout;          /* Default: stderr */

    /* Generic macro (levels: TRACE, DEBUG, INFO, WARN, ERR, FAIL) */
    SOLOG(INFO, "Application started with SoLog v%d", SOLOG_H);

    return 0;
}

Feature Flags

Anything beyond the most basic functionality is optionally enabled through the value you set SOLOG_IMPLEMENTATION to. Every feature macro is defined to a bit mask. OR-ing them together, you can compile-time enable some, all, or none of them. By AND-ing them out of solog_config.features, you can run- time toggle them.

Basic output:

Application started with SoLog v2

With SOLOG_FEATURE_LEVEL:

 INFO | Application started with SoLog v2

License

Dedicated to the public domain under the CC0 1.0 Universal License.