Lob is a C89, cross-platform, MIT-licensed, statically-compiled logging library.
dirkson 5c8b2af892 Updated readme 4 months ago
include Added vlob 6 months ago
meson Updated to new version of osmia. Added boksi option. 4 months ago
src Brought lob up to -w codes 4 months ago
.gitignore Updated to new version of osmia. Added boksi option. 4 months ago
.lvimrc Added boksi support. Updated documentation 10 months ago
LICENSE Initial commit 2 years ago
README.md Updated readme 4 months ago
build Brought lob up to -w codes 4 months ago
meson.build Brought lob up to -w codes 4 months ago
meson_options.txt Updated option to bool, because meson's feature option doesn't do the thing 4 months ago



Lob (or liblob) is a cross-platform, MIT-licensed, statically-compiled logging library written in C99.

It will display errors, warnings, and other messages via stdout, stderr, gui boxes, or direct writes to files. It’s optionally thread safe, and all calls are blocking. It’s designed to be minimal and only include the code you need. It prefers to log successfully over logging quickly, but it should still be quite fast. It should compile on Linux, OSX, and windows.



Hello world

#include <lob_basic.h>
int main() {
	return lob(LOB_ERROR, "Hello %s", "world");

Basic Use

To build, type ‘./build -r’. Output is lib/liblob.a , which should be usable in most C projects.

To build examples, type ‘make examples’. Output is bin/test and bin/basic

The externally visible logging function is:

int lob(const lob_level Level, const char * const Format, ...)

To include predefined levels, include “lob_basic.h”. It provides the follow levels:

LOB_ERROR  //Prints to stderr, log.txt, and creates a guibox. Makes lob() return 0.
LOB_WARN   //Prints to stdout and log.txt. Makes lob() return 1.
LOB_INFO   //Prints to stdout. Makes lob() return 1.
LOB_DEBUG  //Prints to stdout. Makes lob() return 1.

Format is a printf-style formatted string, with a newline appended for you. It is followed by a list of variables, in the printf style.

lob()’s return value is determined by its level. The default levels provided by “lob_basic.h” use 0 for LOB_ERROR, and 1 for others.

Available compile flags

Lob is designed to be statically compiled into whatever it’s used in, and as such most configuration options are compile-time flags. This removes the unused feature from lob entirely in most cases.

You’ll need to clean whenever cflags change: ./build -c

To use a flag, use this format


List of simple compile flags

LOB_NO_TIME        //Disable timestamps
LOB_NO_COLOR       //Disable color output to stdout/err.
LOB_NO_SOURCE_FILE //Disable source file/line number
LOB_NO_ALLOCATE    //If lob runs out of space while processing a gui box, it'll attempt to allocate space. This prevents this behavior.
LOB_NO_FILE        //Disable output method - log file
LOB_NO_STDOUT      //Disable output method - stdout/err
LOB_NO_BOKSI       //Disable output method - Boksi gui boxes
LOB_NO_TINYFD      //Disable output method - tinyfiledialogs gui boxes. Automatically set if Boksi is enabled.

There are also a few more complicated flags.

Example usage:

CFLAGS="-DLOB_TIME_FORMAT=\"[%H:%M:%S] \" -DLOB_BUFFER_SIZE=1024" ./build -r liblob.a

List of more complicated flags

LOB_TIME_FORMAT    //Default "%H:%M:%S" . Uses strftime format.
LOB_RETURN_TYPE    //Default int . You cannot use lob_basic.h if you change this to char*.
LOB_BUFFER_SIZE    //Default 256 . ONLY valid for Boksi or tinyfiledialogs boxes right now. Any message longer than this will result in allocation by default. (See LOB_NO_ALLOCATE)

Advanced Use

Define your own levels! See include/lob_basic.h

If you need to pass in a va_list, you can call “vlob” rather than plain “lob”. It takes all the same arguments, with the exception of a va_list instead of a list of arguments.


  • Add some method to allow users to introduce their own callbacks.
  • Add some method of internet-capable logging.
  • Add logging to syslog.
  • Add process safety


Q: Why “Lob”?

A: Well, it could be clever word play based on the concept of “throwing” errors. Alternatively, I could’ve typo’d the word ‘log’ and decided to just go with it. I’ll let you figure out which one is more likely.