blob: 95d4663b945c407ec4ce7974562125e2950015af (
plain)
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
83
84
85
86
87
|
/*! \file mg_tools.h
* \ingroup muggle
* \brief A few utility functions for standalone and plugin messaging for the vdr muggle plugindatabase
*
* \version $Revision: 1.4 $
* \date $Date$
* \author Ralf Klueber, Lars von Wedel, Andreas Kellner
* \author file owner: $Author$
*
*/
/* makes sure we don't use the same declarations twice */
#ifndef _MUGGLE_TOOLS_H
#define _MUGGLE_TOOLS_H
#include <iostream>
#include <string>
#include <mysql.h>
#define STANDALONE 1 // what's this?
/*!
* \brief Logging utilities
*
* \todo these could be static members in the mgLog class
* \todo code of these functions should be compiled conditionally
*/
//@{
void mgSetDebugLevel (int new_level);
void mgDebug (int level, const char *fmt, ...);
void mgDebug (const char *fmt, ...);
void mgWarning (const char *fmt, ...);
//! \todo mgError should display the message on the OSD. How?
void mgError (const char *fmt, ...);
//@}
#ifdef DEBUG
#define MGLOG(x) mgLog __thelog(x)
#else
#define MGLOG(x) {}
#endif
#ifdef DEBUG
#define MGLOGSTREAM __thelog.getStream()
#else
#define MGLOGSTREAM __thelog.getStream()
#endif
/*! \brief simplified logging class
* \ingroup muggle
*
* Create a local instance at the beginning of the method
* and entering/leaving the function will be logged
* as constructors/destructors are called.
*/
class mgLog
{
public:
enum
{
LOG, WARNING, ERROR, FATAL
} mgLogLevel;
std::ostream & getStream ()
{
return std::cout;
}
mgLog (std::string methodname):m_methodname (methodname)
{
getStream () << m_methodname << " entered" << std::endl;
};
~mgLog ()
{
getStream () << m_methodname << " terminated" << std::endl;
}
private:
std::string m_methodname;
};
std::string trim(std::string const& source, char const* delims = " \t\r\n");
#endif /* _MUGGLE_TOOLS_H */
|