Skip to content
forked from castisdev/logger

boost.log 기반의 cilog포멧 로깅 라이브러리

Notifications You must be signed in to change notification settings

lineCode/logger-1

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

boost.log 기반의 cilog포멧 로깅 라이브러리

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 86.1%
  • CMake 13.9%