source: vendor/synergy/current/lib/base/LogOutputters.h

Last change on this file was 2749, checked in by bird, 19 years ago

synergy v1.3.1 sources (zip).

File size: 3.3 KB
Line 
1/*
2 * synergy -- mouse and keyboard sharing utility
3 * Copyright (C) 2002 Chris Schoeneman
4 *
5 * This package is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * found in the file COPYING that should have accompanied this file.
8 *
9 * This package is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#ifndef LOGOUTPUTTERS_H
16#define LOGOUTPUTTERS_H
17
18#include "BasicTypes.h"
19#include "ILogOutputter.h"
20#include "CString.h"
21#include "stddeque.h"
22
23//! Stop traversing log chain outputter
24/*!
25This outputter performs no output and returns false from \c write(),
26causing the logger to stop traversing the outputter chain. Insert
27this to prevent already inserted outputters from writing.
28*/
29class CStopLogOutputter : public ILogOutputter {
30public:
31 CStopLogOutputter();
32 virtual ~CStopLogOutputter();
33
34 // ILogOutputter overrides
35 virtual void open(const char* title);
36 virtual void close();
37 virtual void show(bool showIfEmpty);
38 virtual bool write(ELevel level, const char* message);
39 virtual const char* getNewline() const;
40};
41
42//! Write log to console
43/*!
44This outputter writes output to the console. The level for each
45message is ignored.
46*/
47class CConsoleLogOutputter : public ILogOutputter {
48public:
49 CConsoleLogOutputter();
50 virtual ~CConsoleLogOutputter();
51
52 // ILogOutputter overrides
53 virtual void open(const char* title);
54 virtual void close();
55 virtual void show(bool showIfEmpty);
56 virtual bool write(ELevel level, const char* message);
57 virtual const char* getNewline() const;
58};
59
60//! Write log to system log
61/*!
62This outputter writes output to the system log.
63*/
64class CSystemLogOutputter : public ILogOutputter {
65public:
66 CSystemLogOutputter();
67 virtual ~CSystemLogOutputter();
68
69 // ILogOutputter overrides
70 virtual void open(const char* title);
71 virtual void close();
72 virtual void show(bool showIfEmpty);
73 virtual bool write(ELevel level, const char* message);
74 virtual const char* getNewline() const;
75};
76
77//! Write log to system log only
78/*!
79Creating an object of this type inserts a CStopLogOutputter followed
80by a CSystemLogOutputter into CLog. The destructor removes those
81outputters. Add one of these to any scope that needs to write to
82the system log (only) and restore the old outputters when exiting
83the scope.
84*/
85class CSystemLogger {
86public:
87 CSystemLogger(const char* title, bool blockConsole);
88 ~CSystemLogger();
89
90private:
91 ILogOutputter* m_syslog;
92 ILogOutputter* m_stop;
93};
94
95//! Save log history
96/*!
97This outputter records the last N log messages.
98*/
99class CBufferedLogOutputter : public ILogOutputter {
100private:
101 typedef std::deque<CString> CBuffer;
102
103public:
104 typedef CBuffer::const_iterator const_iterator;
105
106 CBufferedLogOutputter(UInt32 maxBufferSize);
107 virtual ~CBufferedLogOutputter();
108
109 //! @name accessors
110 //@{
111
112 //! Get start of buffer
113 const_iterator begin() const;
114
115 //! Get end of buffer
116 const_iterator end() const;
117
118 //@}
119
120 // ILogOutputter overrides
121 virtual void open(const char* title);
122 virtual void close();
123 virtual void show(bool showIfEmpty);
124 virtual bool write(ELevel level, const char* message);
125 virtual const char* getNewline() const;
126
127private:
128 UInt32 m_maxBufferSize;
129 CBuffer m_buffer;
130};
131
132#endif
Note: See TracBrowser for help on using the repository browser.