Skip to content

766F6964/log

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Log

Overview

License: MIT

Log is a compact logging library with an easy to use API, written in C.

Features

  • Various logging types (success, error, warning, info, panic)
  • Allows logging to stdout or to a file
  • Flexible formatting of logging messages (printf wrapping)
  • Optional prefixes:
    • Colorized logging type prefix
    • Shortform prefix
    • Timestamp prefix
  • Minimal footprint (No external dependencies)

Usage

An example demonstrating how to log formatted messages to stdout, while having time prefixes and colorized logging type prefixes:

#include "log.h"

int main()
{
    // Configure logger
    log_use_time_prefix(true);
    log_use_short_prefix(false);
    log_use_colored_prefix(true);
    log_set_mode(STDOUT);

    log_info("Loading dataset with id: %d ...", 123);
    log_success("Dataset loaded successfully");

    log_info("Generating datastructure from dataset ...");
    log_warning("Data entry at offset %#08x with value: %s uses invalid offset.", 20, "test");
    log_warning("Data structure created with %d error(s)", 1);

    log_info("Serializing datastructure ...");
    log_error("Failed to serialize datastructure. Entry %d with value(s) x=%.2f y=%.2f are invalid.", 7, 10.5f, 20.5f);

    return 0;
}

About

A compact logging module written in C

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages