Coder Social home page Coder Social logo

clog's Introduction

clog

Very simplistic logging for C.

Description

Logging macros that log to stderr. It takes sprintf formatted arguments. Example:

CLOG_INFO("Hello, %s", "world");
  • CLOG_VERBOSE(). For logging that happens very frequently.
  • CLOG_DEBUG(). Internal debugging information. Rarely interesting for the user.
  • CLOG_INFO(). Information that can be useful for the user.
  • CLOG_WARN(). Something that is not supposed to happen, but we can continue execution safely.
  • CLOG_SOFT_ERROR(). It is clearly an an error, but can be handled with returning an error code. Does not stop execution in Debug.
  • CLOG_NOTICE(). Something is not optimal but is being handled. Usually used for serialization or network. e.g. "latency is high", "packet received out of order".
  • CLOG_ERROR(). An illegal state or operation, we should not handle it in debug and stops execution. In other build types than Debug, execution continues.
  • CLOG_OUTPUT(). Outputs information no matter the log level. Will probably be deprecated.
  • CLOG_ASSERT(expression, ...). Checks that the expression is true, otherwise it issues a CLOG_ERROR with the format string.

Usage

You need to provide a global clog_config g_clog; for it to link.

And in your main(), set a function to the log field that will handle the actual logging. Normally you use the provided clog_console.

#include <clog/clog.h>
#include <clog/console.h> // optional, if you want to use the provided `clog_console`.

clog_config g_clog;

int main(int argc, const char* argv[])
{
    g_clog.log = clog_console;

    return 0;
}

clog's People

Contributors

piot avatar

Watchers

 avatar James Cloos avatar  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.