/*
 * tools.h: some helper classes
 *
 * See the README file for copyright information and how to reach the author.
 *
 * $Id$
 */
#ifndef _TOOLS_H
#define _TOOLS_H
#include <syslog.h>

extern int xmsLogLevel;

#define _ StackLogger   __stl__=StackLogger(__FILE__,__LINE__,__FUNCTION__);
#define SLDEBUG(a...)   void((xmsLogLevel>=LOG_DEBUG)?__stl__.Log(LOG_DEBUG,__FILE__,__LINE__,a):void())
#define SLINFO(a...)    void((xmsLogLevel>=LOG_INFO)?__stl__.Log(LOG_INFO,__FILE__,__LINE__,a):void())
#define SLWARN(a...)    void((xmsLogLevel>=LOG_WARNING)?__stl__.Log(LOG_WARNING,__FILE__,__LINE__,a):void())
#define SLERROR(a...)   void((xmsLogLevel>=LOG_ERR)?__stl__.Log(LOG_ERR,__FILE__,__LINE__,a):void())

class     StackLogger {
public:
  StackLogger(const char*,int,const char*);
 ~StackLogger();

  void    Log(int,const char*,int,const char*,...);

private:
  const unsigned short  hLen;
  const char * name;
  const char * file;
  char         scratch[128];
  char         msg[1024];
  int          line;
  static  int  level;  
  static  const char * fnLog;
  static  bool wantTS;
};


#endif
