Giter VIP home page Giter VIP logo

easylog's Introduction

Linux下简单的日志库

你可以只需要写两三行代码就完成配置,然后就可以轻快记录日志了。

一个小例子:

#include <stdio.h>
#include "easylog.h"

int main(int argc, char* argv[]) {
    easylog_file("test.log");
    easylog_flag_add(EASYLOG_DATE |
            EASYLOG_TIME |        
            EASYLOG_FILE |        
            EASYLOG_LINE |        
            EASYLOG_FUNC);        

    easylog("hello 我的");
    easylog_flag_rm(EASYLOG_DATE);
    easylog("hello 你的");

    return 0;
}

编译     gcc -o main main.c easylog.c

./main

test.log 里面的内容:

2017-06-10 04:42:42.996 main.c 11 main() -- hello 我的
04:42:42.997 main.c 13 main() -- hello 你的

其中各个选项的作用如下:

  • EASYLOG_DATE : 在日志中添加日期
  • EASYLOG_TIME : 在日志中添加时间
  • EASYLOG_FILE : 在日志中添加本日志语句所在的文件名
  • EASYLOG_LINE : 在日志中添加本日志语句所在的文件中的行
  • EASYLOG_FUNC : 在日志中添加本日志语句所在的函数

然后就可以用啦,更详细一些的使用在我的博客(http://www.fengbohello.top/code/easylog)里面也有说明哦~

easylog's People

Contributors

fengbohello avatar

Watchers

 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.