Skip to content

GordonZhang2024/log.cc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Log.cc

A simple logging library for C++

GitHub License Static Badge

Usage

Log.cc is very easy to use.

To use log.cc for your own project, you only need to copy src/log.cc and src/log.h to your own source directory.

Example

#include "log.h"

int main()
{
    logger l("log.txt");
    l.log(ERROR, "error message");
    return 0;
}

Note

Available levels

  • TRACE
  • DEBUG
  • INFO
  • WARNING
  • ERROR
  • FATAL

The full example is in the example/ directory. You can find more useful functions from log.cc

The following examples use l as the default logger name.

Want to format the output?

You can use the log() function in this way, just like printf():

l.log(WARNING, "%d", 1);

Important

Don't forget to set the log level (which is the first argument of the log() function).

Tip

More info

There are also many useful functions in log.cc. You can view the Wiki page for more info.

License

MIT License