Skip to content

thorbenk/chatty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chatty

Logger for both C++ and Python.

Build Status

screencast

Here is the python script that generates the above log:

from chatty import *
import time

log = Logger.getInstance()
log.setLogfile('/tmp/chatty.log')

log.log(Format.header1, Color.green, 'Hello world!')
log.warn('warning: starting example')

example_timer = log.startNewTimer('run example')

with IndentationContextManager() as l:
    l.log(Color.yellow, "indented log")

with TimedLineContextManager('long operation'):
    time.sleep(0.7)

N = 10
with ProgressLoopContextManager('long loop', N) as l:
    for i in range(10):
        time.sleep(0.4)
        l.advanceProgressLoop(1)

log.endTimer(example_timer)

time.sleep(2)

A similar API can be used from C++. Both Python and C++ will share the same logger instance.

Building

On Ubuntu 17.04:

sudo apt install libboost-dev libboost-python-dev libboost-system-dev
sudo apt install libboost-filesystem-dev libboost-serialization-dev
sudo apt install libboost-date-time-dev libboost-test-dev
sudo apt install libboost-regex-dev libboost-thread-dev ninja-build cmake

mkdir build && cd build
cmake -GNinja \
  -DCMAKE_INSTALL_PREFIX=~/inst \
  -DPYTHON_SITE_PACKAGES=~/inst/lib/python-2.7/site-packages \
  -DCMAKE_BUILD_TYPE-Release ..
ninja
ctest .

About

Logger for both C++ and Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published