aboutsummaryrefslogtreecommitdiff
path: root/src/multilogtext.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/multilogtext.h')
-rw-r--r--src/multilogtext.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/multilogtext.h b/src/multilogtext.h
new file mode 100644
index 0000000..aa32405
--- /dev/null
+++ b/src/multilogtext.h
@@ -0,0 +1,70 @@
1#ifndef MULTILOGTEXT_H
2#define MULTILOGTEXT_H
3
4#include "multilogchannel.h"
5
6/**
7 * Simple MultiLogChannel that takes the logdata, formats it textually, and
8 * writes it to a text device, either a file or the screen, yay! This takes
9 * the place of the old standard logging facility.
10 * The entries in the format follow the standard printf % style, and are as
11 * follows:
12 * <ul>
13 * <li>%y - current year</li>
14 * <li>%m - current month</li>
15 * <li>%d - current day</li>
16 * <li>%h - current hour (24-hour format)</li>
17 * <li>%M - current minute</li>
18 * <li>%s - current seccond</li>
19 * <li>%l - Loglevel (numerical)</li>
20 * <li>%f - Filename</li>
21 * <li>%L - Line number</li>
22 * <li>%t - Full text of the log entry</li>
23 * </ul>
24 *@author Mike Buland
25 */
26class MultiLogText : public MultiLogChannel
27{
28public:
29 /**
30 * Construct a MultiLogText object around a specific filename and format.
31 * The file named by sFileName will be opened for writting in text+append
32 * mode. No existing data will be destroyed.
33 *@param sFileName The file to output log-data to.
34 *@param lpFormat The format using the above specifications to be used for
35 * every log entry.
36 */
37 MultiLogText( const char *sFileName, const char *lpFormat );
38
39 /**
40 * Construct a MultiLogText object around a specific file and format.
41 * The file descriptor passed in should describe an already opened and set-
42 * up file or device. This could easily be a socket or stdout or stderr.
43 *@param nFileDesc The already opened descriptor to send data to.
44 *@param lpFormat The format using the above specifications to be used for
45 * every log entry.
46 */
47 MultiLogText( int nFileDesc, const char *lpFormat );
48
49 /**
50 * Destroy the object.
51 */
52 ~MultiLogText();
53
54 bool openLog();
55 bool append( MultiLog::LogEntry *pEntry );
56 bool closeLog();
57
58 /**
59 * Change the log format on the fly.
60 *@param lpFormat The new format to use for all future log entries.
61 *@returns True if everything was fine, false for catastrophic failure.
62 */
63 bool setLogFormat( const char *lpFormat );
64
65private:
66 int nFD; /**< The file descriptor we're writing to. */
67 char *lpFormat; /**< The format that we're using, converted for printf. */
68};
69
70#endif