GithubHelp home page GithubHelp logo

log4c's Introduction

log4c

log4c is a simple thread safe fast logging library for C and C++.

sreenshot

Usage

Do not put "\n" at the end of the logging functions, they are added by default.
If you want to disable logging define LOG4C_DISABLE before including the library.

Each level of logs can be disabled with LOG4C_DISABLE_<NAME_OF_LOG_LEVEL> macro, Example: #define LOG4C_DISABLE_TRACE

You can use this preprocessor variables to control how library works. Do not #define these, instead specify them to the compiler like -DLOG4C_RELEASE otherwise these macros will probably not work.

LOG4C_ENABLE_BOLD_COLORS /* Works only if LOG4C_DISABLE_COLOR is not set */
LOG4C_RELEASE /* Disables printing file properties and time */
LOG4C_DISABLE_COLORS /* Disable all colors for log information names */

Logging functions

log_notag(...);
log_ok(...);
log_trace(...);
log_debug(...);
log_info(...);
log_warn(...);
log_error(...);
log_fatal(...);

Thread safety, which is not enabled by default.

log_enable_thread_safe();   /* Enables thread safety globally  */
log_disable_thread_safe();  /* Disables thread safety globally */

Quiet mode, set to 0 by default, set quiet to 1 enable.

log_set_quiet(unsigned int quiet); /* If enabled do not print to stderr. */

Set the minimum warning level.

log_set_level(int level);

Output log to file. Note if you use log_append_file it will open the file in the append mode to prevent loss of old data. If this is not what you want you can open the file in any mode you want and call log_append_fp

log_append_file(const char *path);
log_append_fp(FILE *file_descriptor);
log_detach_fp(); /* Remove file descriptor. Disable logging to file. */

Note

Recently I changed a lot of code and didn't have any time to check if it works on Windows. If the current version doesn't work on Windows please revert back to this b56416ff26198a3d7d2fd803a7a6245aff6e5ded commit.

I also removed couple of features like being able to disable colors. I find it to be really useless as almost all the terminals are able to print the colors without a problem.

log4c's People

Contributors

hsnovel avatar

Watchers

 avatar

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.