Giter Club home page Giter Club logo

log.c's Introduction

log.c

A simple logging library implemented in C99

screenshot

Usage

log.c and log.h should be dropped into an existing project and compiled along with it. The library provides 6 function-like macros for logging:

log_trace(const char *fmt, ...);
log_debug(const char *fmt, ...);
log_info(const char *fmt, ...);
log_warn(const char *fmt, ...);
log_error(const char *fmt, ...);
log_fatal(const char *fmt, ...);

Each function takes a printf format string followed by additional arguments:

log_trace("Hello %s", "world")

Resulting in a line with the given format printed to standard output:

20:18:26 TRACE src/main.c:11: Hello world

And to the output files:

2047-03-11 20:18:26 TRACE src/main.c:11: Hello world

Detailed documentation is provided in the 'log.h' file

Configure library

To alter the default settings, the library has to be compiled with the 'LOGC__USER_SETTINGS' flag. This way, a 'log_conf.h' file can be specified to alter the default settings.

Differences with the original project from rxi

The most interesting pull-requests (to me at least) have been integrated. Thanks to the following for their indirect contribution:

My changes:

  • Code indentation changed to 4 spaces
  • Added doxygen-style documentation for all functions and structures
  • Log levels enum converted to a typedef
  • Ability to configure library with the 'log_conf.h' file
  • Renamed 'udata' variables in code to more meaningful
  • Added sample source files
    • basic Is a basic example, to log to stdout and to a file
    • callbacks Is a minimal example using callbacks with different log levels
    • threading Shows a threading example

License

This library is free software; you can redistribute it and/or modify it under the terms of the MIT license. See LICENSE for details.

log.c's People

Contributors

rxi avatar bdeliers avatar

Stargazers

 avatar Eric Johnson avatar Brad Avenson avatar

Watchers

 avatar

Forkers

kevinrohn

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.