GithubHelp home page GithubHelp logo

linecode / logger-facade Goto Github PK

View Code? Open in Web Editor NEW

This project forked from malirod/logger-facade

0.0 2.0 0.0 1.7 MB

Logger facade for log4cplus and boost loggers

License: MIT License

Python 23.40% Shell 18.39% C++ 58.21%

logger-facade's Introduction

Build Status

logger-facade

Allows to switch between different loggers keeping the same interface. Supported log4cplus and Boost Log

Platform

Ubuntu 16.04: Clang 3.8, GCC 5.4

C++11 Standard is used.

Setup

Install Boost

Use pre-build Boost lib

Use the following repository: https://github.com/malirod/boost-bin

Use appropriate branch. Branch name containts info about used env and options to build Boost.

E.g.

https://github.com/malirod/boost-bin/tree/boost-1.61-ubuntu-16.04-x64-clang-5.8-release-c++11-static-multi

Build Boost manually from sources

If pre-build version doesn't fit your needs (OS, compiler etc) then build Boost manually.

Download and unzip to some dir (e.g. ~/libs/boost_1_61_0) latest stable version from Boost site.

Go the unzipped directory and run commands

./bootstrap.sh --prefix=./build
./b2 --with=all -j2 install

Set environment variable

Set env pointing to the boost install dir (in ~/.profile or ~/.bashrc)

export BOOST_HOME=~/libs/boost_1_61_0/build

Restart terminal, or reload config with source ~/.profile (source ~/.bashrc)

Install log4cplus

Build from sources

Can work with either 1.1.x or 1.2.0. Run the following commands in some "libs" directory to setup 1.2.0

sudo apt-get -y install autotools-dev automake
wget -O log4cplus-1.2.0.tar.xz http://heanet.dl.sourceforge.net/project/log4cplus/log4cplus-stable/1.2.0/log4cplus-1.2.0.tar.xz
tar xf log4cplus-1.2.0.tar.xz
cd log4cplus-1.2.0
./configure CXX="clang++" --disable-shared --enable-static --prefix=$PWD/build
make -j$(nproc) && make install

Set environment variable

Set env pointing to the log4cplus install dir (in ~/.profile or ~/.bashrc)

export LOG4CPLUS_HOME=~/libs/boost_1_61_0/build

Restart terminal, or reload config with source ~/.profile (source ~/.bashrc)

Setup git hook

Run python infrastructure/tools/install_hooks.py

This will allow to perform some code checks locally before posting changes to server.

Install pylint - python checker

sudo apt-get install pylint

Install cpplint - c++ style checker

sudo apt-get install python-pip
sudo pip install cpplint

Build

In the project root call

./waf configure --logger=log4cplus clean_release build_release clean_debug build_debug -v -j2

Clang is used by defaul. Fallback to GCC if Clang not found. To use GCC call

CXX=g++ ./waf configure

Build with sanitizers (clang)

Use the following option for configuration --sanitize. Applicable to debug build only. Known values are:

  • asan: address
  • tsan: thread
  • msan: memory
  • ubsan: undefined behaviour

Example

./waf configure --logger=log4cplus --sanitize=asan
./waf build_debug -v
ASAN_OPTIONS="detect_leaks=1" ./build/debug/testrunner

Run

Run from project root. It's expected that config is located in the project root.

build/debug/testrunner

Basic usage

Init logging and log with global logger

#include "logger.h"

DECLARE_GLOBAL_GET_LOGGER("Logger.Global")

int main(int argc, char** argv) {
  INIT_LOGGER("logger.cfg");

  LOG_TRACE("Trace global line");
  LOG_DEBUG("Debug global line");
  LOG_INFO("Info global line");
  LOG_WARN("Warn global line");
  LOG_ERROR("Error global line");
  LOG_FATAL("Fatal global line");
}

Class logger and traces

namespace Foo {
class Bar {
 public:
  DECLARE_GET_LOGGER("Foo.Bar")

  void OutputTestLogLines() {
    LOG_TRACE("Trace class line");
    LOG_DEBUG("Debug class line");
    LOG_INFO("Info class line");
    LOG_WARN("Warn class line");
    LOG_ERROR("Error class line");
    LOG_FATAL("Fatal class line");
  }

  void OutputAutoTrace() {
    LOG_AUTO_TRACE();
    LOG_TRACE("Method with auto trace");
  }
};
}  // namespace Foo

logger-facade's People

Contributors

agaliuzov avatar malirod 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.