Git Product home page Git Product logo

clog's Introduction

A simple version of spdlog

Support synchronize and asynchronize logger

Support stdout and roll file output

simple output

#include <vector>
#include "clog/clog.h"

// synchronize log, output to terminal
// which use default logger
clog::info("hello world. This use default logger");
clog::debug("you can use format like {}, number:{:.2f}", "fmtlib", 12.2311);
// set log level
clog::setLogLevel(clog::LogLevel::INFO);
clog::debug("I will not be shown");
// use fmtlib 
std::vector<int> nums{1, 2, 3, 4};
clog::error("vector nums: [{}]", fmt::join(nums, ", "));

// you can also set output pattern
clog::setPattern("[%M-%D %h:%m:%s.%f] [%L] [thread: %t] %v");
clog::info("change format");

// you can also use macro to log
CLOG_ERROR("use macro: {}", "hhh");
CLOG_WARN("Also use default logger, so pattern and level had been set");

Attention: only macro log can output source info(source filename and line number).

format

Use clog::setPattern to set log format. All support format flag list here:

  • %n: logger name.
  • %l: log level, such as info, debug.
  • %L: simplified log level, such as I, D.
  • %Y: year, such as 2001.
  • %M: month, such as 03.
  • %D: day, such as 29.
  • %h: hour.
  • %m: minute.
  • %s: second.
  • %e: millisecond.
  • %f: microsecond.
  • %t: thread id.
  • %v: log content.
  • %u: source filename.
  • %w: function name.
// set format of default logger
clog::setPattern("[%M-%D %h:%m:%s.%f] [%L] [thread: %t] %v");

See tests/example.cpp for more.

clog's People

Contributors

xiaoqief avatar

Stargazers

参天尽物 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.