photoid

welcome to cia's www public space




current directory: /site_root/computing/

a state-threads logger library

a small footprint logging library to be used with state threads or without :)

Discuss this article on forums

Tags: state threads  logging  logger 


Table Of Contents
using the state threads library logger


when i program with state threads i want to log things on local file system. i wrote this small library so i can log to err.log and out.log, do ugly debug or don't do debug at all, signal warnings, show infos, etc.
to compile it, do
gcc -DDEBUG_MODE -I. -I/path/to/state_threads_include -Wall -g -DOUT_LOGFILE=\"logs/out.log\" -DERR_LOGFILE=\"logs/err.log\" -c log.c

before using it, after a successfull st_init() call st_log_init().
the loggers are defined as macros in log.h
calling the loggers:
debug: dbg("i'm here man! %s", some_chars)
warning: warn("this is kinda wrong, var should be %d", somevar)
info: inf("some useful info , i just sent this string: %s to port %d", string, port);
just printing: out("ok, there are %d guys knocking on my door", num_guys);