blob: e53764b7d6bb05e04d251fc686ad33e711788c43 [file] [log] [blame]
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18
19// -=- Logger.h - The Logger class.
20
21#ifndef __RFB_LOGGER_H__
22#define __RFB_LOGGER_H__
23
24#include <stdarg.h>
25#include <stdio.h>
26
27// Each log writer instance has a unique textual name,
28// and is attached to a particular Logger instance and
29// is assigned a particular log level.
30
31namespace rfb {
32
33 class Logger {
34 public:
35
36 // -=- Create / Destroy a logger
37
38 Logger(const char* name);
39 virtual ~Logger();
40
41 // -=- Get the name of a logger
42
43 const char *getName() {return m_name;}
44
45 // -=- Write data to a log
46
47 virtual void write(int level, const char *logname, const char *text) = 0;
48 void write(int level, const char *logname, const char* format, va_list ap);
49
50 // -=- Register a logger
51
52 void registerLogger();
53
54 // -=- CLASS FIELDS & FUNCTIONS
55
56 static Logger* loggers;
57
58 static Logger* getLogger(const char* name);
59
60 static void listLoggers();
61
62 private:
63 bool registered;
64 const char *m_name;
65 Logger *m_next;
66 };
67
68};
69
70#endif // __RFB_LOGGER_H__