GithubHelp home page GithubHelp logo

logger-1's Introduction

Castis Logger

Boost.log기반의 CiLogger formatting 지원 logging 라이브러리입니다.

Features

  • header-only
  • severity levels
  • file rotation (size 기반, default = 10MB)
  • auto flushing on/off
  • iostream 과 printf 스타일을 모두 지원
  • asyncronous logging

Basic Example

#include "castislogger.h"

int main()
{
  castis::logger::init_logger("example", "1.0.0");

  // support severity levels
  CILOG(debug) << "A debug message";
  CILOG(error) << "An error message";

  // support both streams and printf-style format
  CILOG(report) << "strings(" << "abc" << "), integers(" << 123 << ")";
  CILOGF(report, "strings(%s), integers(%d)", "abc", 123);

  return 0;
}

이 예제는 ./log/2014-08/2014-08-13_example.log 경로의 파일을 생성하여 아래와 같은 log를 기록합니다.

example,1.0.0,2014-08-13,19:10:28.872906,Debug,example.cpp::main:8,,A debug message
example,1.0.0,2014-08-13,19:10:28.873859,Error,example.cpp::main:9,,An error message
example,1.0.0,2014-08-13,19:10:28.873894,Report,example.cpp::main:12,,strings(abc), integers(123)
example,1.0.0,2014-08-13,19:10:28.873920,Report,example.cpp::main:13,,strings(abc), integers(123)

Asyncronous Logging Example

Asyncronous logging을 사용하면 I/O 동작을 별도의 thread에서 수행하므로 application의 성능을 향상시킬 수 있습니다.

#include "castislogger.h"

int main()
{
  auto sink = castis::logger::init_async_logger("example", "1.0.0");

  CILOG(debug) << "A debug message";
  CILOG(error) << "An error message";

  castis::logger::stop_logger(sink);
  return 0;
}

Performance

각각 1,000,000 라인의 로그를 남기는 성능 테스트 결과입니다.(auto-flush enabled)

latency 측정은 profc를 이용했습니다.

$ ./example && ./example_async
--------------------------------------------------------------
name                           count      elapsed      us/call
logging_printf_style         1000000      10291ms         10us
logging                      1000000       7260ms          7us

--------------------------------------------------------------
name                           count      elapsed      us/call
logging_async                1000000       3725ms          3us

Dependency

  • Boost 1.56
    • log
    • thread
    • filesystem
    • system
    • regex
    • format

logger-1's People

Contributors

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