GithubHelp home page GithubHelp logo

rfarr / logdefer-cxx Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hoytech/logdefer-cxx

0.0 2.0 0.0 145 KB

Log::Defer C++11 implementation

License: BSD 2-Clause "Simplified" License

C++ 100.00%

logdefer-cxx's Introduction

LogDefer-CXX

Description

Log::Defer C++11 implementation

This is a logger implementation of the Log::Defer format in C++11.

It uses Kazuho Oku's picojson library to serialise messages.

Usage

The usage tries to be as similar as possible to the reference Perl implementation (although it assumes JSON where the perl one doesn't).

The basic usage is to create a new LogDefer object. The constructor requires one argument: A lambda callback function. This callback will be invoked when the LogDefer object's destructor is called. That is, when it goes out of scope or when the last reference to it has been destroyed.

Here is a simple example:

{
  LogDefer logger([](const std::string &json) {
                    // Normally we'd write this to a file/syslog/etc
                    std::cout << json << std::endl;
                  });

  logger.info("Processed some stuff");
  logger.warn("some warning!");

} // <-- logger goes out of scope so callback is invoked now

Todo

  • Timers (will need to use weak pointers)
  • Data (will need to expose picojson interface)
  • Make sure that the desctructor can't throw exceptions

See Also

The Log::Defer perl reference implementation

Michael Pucyk's LogDefer Python module

One way to display these logs is the log-defer-viz visualisation tool

Author and Copyright

Copyright (c) 2014 Doug Hoyte

This library is distributed under the 2-clause BSD license so you can basically do whatever you want with it.

logdefer-cxx's People

Contributors

hoytech avatar

Watchers

James Cloos avatar Richard Farr 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.