Giter VIP home page Giter VIP logo

tinyclog's Introduction

TinyCLog

TinyCLog is mini C logging library. It is header only and thread safety.

2021-07-21 21:47:18	example.c:main:4	DEBUG	this is a debug #1
2021-07-21 21:47:18	example.c:main:5	INFO	this is a info #2
2021-07-21 21:47:18	example.c:main:6	WARN	this is a warning #3
2021-07-21 21:47:18	example.c:main:7	ERROR	this is a error #4
2021-07-21 21:47:18	example.c:main:8	FATAL	this is a fatal #5

Usage

Copy folder tiny_c_log to your project directory.

#include "tiny_c_log/log_posix.h"

int main(void) {
  LOG_DEBUG("this is a debug #%d", 1);
  LOG_INFO("this is a info #%d", 2);
  LOG_WARN("this is a warning #%d", 3);
  LOG_ERROR("this is a error #%d", 4);
  LOG_FATAL("this is a fatal #%d", 5);

  return 0;
}

Build

Since TinyCLog is header only, to avoid symbols redefined, all the definition of symbols with external linkage are wraped in #ifdef TINY_C_LOG_POSIX_IMPL. So you have to make sure that macro TINY_C_LOG_POSIX_IMPL is defined in one and only one compilation unit. USER_LOGFILE_LOCATION and USER_LOG_LEVEL are optional and are used to configure the location of log files and logging level.

gcc -DTINY_C_LOG_POSIX_IMPL -DUSER_LOGFILE_DIR=\"example.log\" -DUSER_LOG_LEVEL=DEBUG -c example.c
gcc -c mutilthread.c
gcc -pthread -o example example.o mutilthread.o

tinyclog's People

Contributors

coyorkdow avatar

Stargazers

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