blob: b75594c963483b7e129554ea110763b82fa777d5 [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
Steve Kondik5ec2d092017-07-08 02:06:16 -070031#ifdef __GNUC__
32# define __printf_attr(a, b) __attribute__((__format__ (__printf__, a, b)))
33#else
34# define __printf_attr(a, b)
35#endif // __GNUC__
36
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000037namespace rfb {
38
39 class Logger {
40 public:
41
42 // -=- Create / Destroy a logger
43
44 Logger(const char* name);
45 virtual ~Logger();
46
47 // -=- Get the name of a logger
48
49 const char *getName() {return m_name;}
50
51 // -=- Write data to a log
52
53 virtual void write(int level, const char *logname, const char *text) = 0;
Steve Kondik5ec2d092017-07-08 02:06:16 -070054 void write(int level, const char *logname, const char* format, va_list ap) __printf_attr(4, 0);
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000055
56 // -=- Register a logger
57
58 void registerLogger();
59
60 // -=- CLASS FIELDS & FUNCTIONS
61
62 static Logger* loggers;
63
64 static Logger* getLogger(const char* name);
65
66 static void listLoggers();
67
68 private:
69 bool registered;
70 const char *m_name;
71 Logger *m_next;
72 };
73
74};
75
76#endif // __RFB_LOGGER_H__