1 |
|
---|
2 | /*
|
---|
3 | * bs_logger.h:
|
---|
4 | * header file for bs_logger.cpp. See remarks there.
|
---|
5 | *
|
---|
6 | *@@include #define INCL_WINWORKPLACE
|
---|
7 | *@@include #include <os2.h>
|
---|
8 | *@@include #include <stdarg.h>
|
---|
9 | *@@include #include "base\bs_string.h"
|
---|
10 | *@@include #include "base\bs_logger.h"
|
---|
11 | */
|
---|
12 |
|
---|
13 | /*
|
---|
14 | * This file Copyright (C) 1999-2008 Ulrich Mller.
|
---|
15 | * This program is free software; you can redistribute it and/or modify
|
---|
16 | * it under the terms of the GNU General Public License as published by
|
---|
17 | * the Free Software Foundation, in version 2 as it comes in the COPYING
|
---|
18 | * file of this distribution.
|
---|
19 | * This program is distributed in the hope that it will be useful,
|
---|
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
22 | * GNU General Public License for more details.
|
---|
23 | */
|
---|
24 |
|
---|
25 | #ifndef WARPIN_LOGGER_HEADER_INCLUDED
|
---|
26 | #define WARPIN_LOGGER_HEADER_INCLUDED
|
---|
27 |
|
---|
28 | /* ******************************************************************
|
---|
29 | *
|
---|
30 | * Logger exceptions
|
---|
31 | *
|
---|
32 | ********************************************************************/
|
---|
33 |
|
---|
34 | /*
|
---|
35 | *@@ BSLoggerExcpt:
|
---|
36 | *
|
---|
37 | *@@added V0.9.9 (2001-03-30) [umoeller]
|
---|
38 | */
|
---|
39 |
|
---|
40 | class BSLoggerExcpt : public BSExcptBase
|
---|
41 | {
|
---|
42 | public:
|
---|
43 | BSLoggerExcpt(const char *pcsz)
|
---|
44 | {
|
---|
45 | _ustrDescription.assignUtf8(pcsz);
|
---|
46 | }
|
---|
47 | };
|
---|
48 |
|
---|
49 | /* ******************************************************************
|
---|
50 | *
|
---|
51 | * Logger base class
|
---|
52 | *
|
---|
53 | ********************************************************************/
|
---|
54 |
|
---|
55 | /*
|
---|
56 | *@@ BSMemLoggerBase:
|
---|
57 | * generic memory logger class which supports
|
---|
58 | * putting any kind of data into a single
|
---|
59 | * memory block. Useful for storing logs
|
---|
60 | * in an INI file.
|
---|
61 | *
|
---|
62 | * The logger classes allow for storing log entries,
|
---|
63 | * which are simply blocks of memory in any format.
|
---|
64 | *
|
---|
65 | * The format of data stored in the logger depends
|
---|
66 | * solely on the caller. The logger itself has no
|
---|
67 | * idea what the data it stores means. It is the
|
---|
68 | * exclusive responsibility of the caller to write
|
---|
69 | * and parse that data. This could be a sequence of
|
---|
70 | * null-terminated strings, but need not be.
|
---|
71 | *
|
---|
72 | * There are several Append() methods which allow
|
---|
73 | * the caller to append a chunk of memory to the
|
---|
74 | * logger.
|
---|
75 | *
|
---|
76 | * A mem logger can quickly store all its data in an
|
---|
77 | * OS/2 INI file thru the BSMemLoggerBase::Store method.
|
---|
78 | * The logger can then be reconstructed later from the
|
---|
79 | * INI entry though the BSMemLoggerBase::Load method.
|
---|
80 | *
|
---|
81 | * Unmodified subclasses of this are declared in bs_config.h
|
---|
82 | * and used all over the place to log changes made to the system,
|
---|
83 | * which can then be stored in the database and passed to the
|
---|
84 | * "Undo" classes/methods to undo the changes again. All
|
---|
85 | * those subclasses are simply declared so that the different
|
---|
86 | * logger formats can be watched by the compiler.
|
---|
87 | *
|
---|
88 | *@@changed V0.9.0 (99-11-01) [umoeller]: renamed from LoggerBase
|
---|
89 | *@@changed V0.9.0 (99-11-01) [umoeller]: moved this here from config.*
|
---|
90 | *@@changed V0.9.9 (2001-03-30) [umoeller]: added BSLoggerRoot abstract base class
|
---|
91 | *@@changed V0.9.9 (2001-03-30) [umoeller]: renamed from BSLoggerBase
|
---|
92 | *@@changed V0.9.20 (2002-07-22) [umoeller]: added copy constructor to avoid flat copy
|
---|
93 | *@@changed WarpIN V1.0.10 (2006-04-05) [pr]: added Clear method
|
---|
94 | *@@changed WarpIN V1.0.18 (2008-10-06) [pr]: added Store(PXINI...) and Load(PXINI...)
|
---|
95 | */
|
---|
96 |
|
---|
97 | class BSMemLoggerBase
|
---|
98 | {
|
---|
99 | public:
|
---|
100 | char *_pabLogString;
|
---|
101 | unsigned long _cbLogString;
|
---|
102 |
|
---|
103 | BSMemLoggerBase();
|
---|
104 | ~BSMemLoggerBase();
|
---|
105 |
|
---|
106 | BSMemLoggerBase(const BSMemLoggerBase &l);
|
---|
107 |
|
---|
108 | BSMemLoggerBase& operator=(const BSMemLoggerBase &l);
|
---|
109 |
|
---|
110 | // override virtual method
|
---|
111 | void StoreData(const char *pabData, unsigned long cbData);
|
---|
112 |
|
---|
113 | void Append(const char *pabData, unsigned long cbData);
|
---|
114 | // void Append(const char *pcsz);
|
---|
115 | void Append(const ustring &ustr);
|
---|
116 |
|
---|
117 | void Clear(void);
|
---|
118 |
|
---|
119 | BOOL Store(HINI hini, const char *pszApp, const char *pszKey) const;
|
---|
120 | BOOL Store(PXINI pXIni, const char *pszApp, const char *pszKey) const;
|
---|
121 | BOOL Load(HINI hini, const char *pszApp, const char *pszKey);
|
---|
122 | BOOL Load(PXINI pXIni, const char *pszApp, const char *pszKey);
|
---|
123 | };
|
---|
124 |
|
---|
125 | /*
|
---|
126 | *@@ BSFileLogger:
|
---|
127 | * logger which writes to a file instead of
|
---|
128 | * storing the log entries in memory.
|
---|
129 | *
|
---|
130 | * This needs a file name in the constructor.
|
---|
131 | * The logger still doesn't know what data the
|
---|
132 | * log contains but simply writes it out to
|
---|
133 | * disk.
|
---|
134 | *
|
---|
135 | *@@added V0.9.9 (2001-03-30) [umoeller]
|
---|
136 | *@@changed WarpIN V1.0.14 (2006-11-30) [pr]: added WriteRaw
|
---|
137 | */
|
---|
138 |
|
---|
139 | class BSFileLogger
|
---|
140 | {
|
---|
141 | string _strFileName;
|
---|
142 | int _indent;
|
---|
143 | FILE *_File;
|
---|
144 |
|
---|
145 | public:
|
---|
146 | BSFileLogger(ULONG ulDummy,
|
---|
147 | const char *pcszFilename);
|
---|
148 | virtual ~BSFileLogger();
|
---|
149 |
|
---|
150 | void IncIndent(int i);
|
---|
151 |
|
---|
152 | void WriteV(const char *pcszFormat,
|
---|
153 | va_list arg_ptr);
|
---|
154 |
|
---|
155 | void Write(const char *pcszFormat,
|
---|
156 | ...);
|
---|
157 |
|
---|
158 | // WarpIN V1.0.14 (2006-11-30) [pr]
|
---|
159 | void WriteRawV(const char *pcszFormat,
|
---|
160 | va_list arg_ptr);
|
---|
161 |
|
---|
162 | void WriteRaw(const char *pcszFormat,
|
---|
163 | ...);
|
---|
164 | };
|
---|
165 |
|
---|
166 | /* ******************************************************************
|
---|
167 | *
|
---|
168 | * Package loggers
|
---|
169 | *
|
---|
170 | ********************************************************************/
|
---|
171 |
|
---|
172 | // we define these here because they are used both in fe_script.h
|
---|
173 | // and fe_package.h
|
---|
174 |
|
---|
175 | /*
|
---|
176 | *@@ BSRequiresLogger:
|
---|
177 | * logger used in FEPackageBase to
|
---|
178 | * store five- or six-part package IDs
|
---|
179 | * which are required by a package.
|
---|
180 | *
|
---|
181 | *@@added V0.9.1 (2000-01-07) [umoeller]
|
---|
182 | */
|
---|
183 |
|
---|
184 | class BSRequiresIDsLogger : public BSMemLoggerBase { };
|
---|
185 |
|
---|
186 | /*
|
---|
187 | *@@ BSRequiresStringsLogger:
|
---|
188 | * logger used in FEArcPackagePck to store
|
---|
189 | * the REQUIRES attributes exactly as they
|
---|
190 | * are found in the archive. This is translated
|
---|
191 | * later after all packages have been parsed.
|
---|
192 | *
|
---|
193 | *@@added V0.9.1 (2000-01-07) [umoeller]
|
---|
194 | */
|
---|
195 |
|
---|
196 | class BSRequiresStringsLogger : public BSMemLoggerBase { };
|
---|
197 |
|
---|
198 | /*
|
---|
199 | *@@ BSCreatedDirsLogger:
|
---|
200 | * logger used in FEArcPackagePck to store
|
---|
201 | * the directories that were actually created
|
---|
202 | * during the install. This is appended to
|
---|
203 | * while files are being unpacked.
|
---|
204 | *
|
---|
205 | *@@added V0.9.20 (2002-07-22) [umoeller]
|
---|
206 | */
|
---|
207 |
|
---|
208 | class BSCreatedDirsLogger : public BSMemLoggerBase { };
|
---|
209 |
|
---|
210 | #endif
|
---|
211 |
|
---|
212 |
|
---|