File: aclogger.h

package info (click to toggle)
apt-cacher-ng 0.7.27-1~bpo70+1
  • links: PTS
  • area: main
  • in suites: wheezy-backports
  • size: 1,740 kB
  • sloc: cpp: 13,987; sh: 519; perl: 442; ansic: 414; makefile: 77
file content (82 lines) | stat: -rw-r--r-- 1,854 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef _ACLOGGER_H
#define _ACLOGGER_H

#include "config.h"
#include "meta.h"
#include "acbuf.h"

#define LOG_FLUSH 1
#define LOG_MORE 2
#define LOG_DEBUG 4


#ifdef DEBUG

struct t_logger
{
	t_logger(const char *szFuncName, const void * ptr); // starts the logger, shifts stack depth
	~t_logger();
	tSS & GetFmter();
	void Write(const char *pFile=NULL, unsigned int nLine=0);
private:
	tSS m_strm;
	pthread_t m_id;
	unsigned int m_nLevel;
	const char * m_szName;
	uintptr_t callobj;
	// don't copy
	t_logger(const t_logger&);
	t_logger operator=(const t_logger&);
};
#define USRDBG(msg) LOG(msg)
#else
// print some extra things when user wants debug with non-debug build
#define USRDBG(msg) { if(acfg::debug & LOG_DEBUG) {aclog::err( tSS()<<msg); } }
#endif


namespace aclog
{

      bool open();
      void close(bool bReopen);
      void transfer(char cLogType, uint64_t nCount, const char *szClient, const char *szPath);
      void err(const char *msg, const char *client=NULL);
      void misc(const mstring & sLine, const char cLogType='M');
      inline void err(cmstring &msg) { err(msg.c_str()); }
      inline void err(const tSS& msg) { err(msg.c_str()); }
      void flush();
      
      void GenerateReport(mstring &);
      
      class tRowData
      {
      public:
      	uint64_t byteIn, byteOut;
      	unsigned long reqIn, reqOut;
      	time_t from, to;
      	tRowData() : byteIn(0), byteOut(0), reqIn(0), reqOut(0), from(0), to(0) 
      	{};
      	/*
      	tRowData(const tRowData &a) : 
      		byteIn(a.byteIn), byteOut(a.byteOut),
      		reqIn(a.reqIn), reqOut(a.reqOut),
      		from(a.from), to(a.to)
      	{
      	};
      	*/
      private:
    	 // tRowData & operator=(const tRowData &a);
      };

      mstring GetStatReport();

}

//#define TIMEFORMAT "%a %d/%m"
#define TIMEFORMAT "%Y-%m-%d %H:%M"


#endif