Giter Site home page Giter Site logo

slog's Introduction

SLOG - Simple Logger for C and C++

This is a simple logging library for C and C++.

Usage

  • add files slog.h and slog.c into your project;
  • initialize the library on program start, for example in main function;
  • use macroses SLOG* for logging.

Example

#include "slog/slog.h"

#define TAG "test"

int main(void)
{
  /* Library initialization.  Must be called only once. */
  SLOG_Init(SLOG_STDERR, "example01-log.txt");

  /* Settings log level.
   * Log all messages to console and all to the file.
   * Default settings are: all messages to file and >= INFO to console. */
  SLOG_SetLevel(SLOG_DEBUG, SLOG_DEBUG);

  SLOGD(TAG, "debug message");
  SLOGI(TAG, "info");
  SLOGW(TAG, "warning");
  SLOGE(TAG, "error");

  SLOGI(TAG, "formatted message (%d, %s)", 123, "bar");

  /* Library deinitialization. */
  SLOG_Deinit();
  return 0;
}

Output of the program:

2013/03/14 00:42:56 DEBUG   [test            ] debug message
2013/03/14 00:42:56 INFO    [test            ] info
2013/03/14 00:42:56 WARNING [test            ] warning
2013/03/14 00:42:56 ERROR   [test            ] error
2013/03/14 00:42:56 INFO    [test            ] formatted message (123, bar)

Design goals

  • simple in usage and implementation;
  • fast compilation;
  • logging to console and/or into a file;
  • suitable for C and C++;
  • printf-like formatting;
  • no overhead when logging is disabled;
  • cross-platform (Unix, Windows);
  • suitable for open-source and commercial products;

License

The MIT License (MIT)

You can use this library in commercial and open-source projects. No attribution is required. Please see the full text of the license in LICENSE.txt

Additional usage notes

Logging can be completely disabled when the program is compiled with define SLOG_DISABLED.

Resources

Home page: https://bitbucket.org/gennady/slog

slog's People

Contributors

gtrafimenkov avatar

Stargazers

Jan Šimek 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.