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-2006 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 | */
|
---|
95 |
|
---|
96 | class BSMemLoggerBase
|
---|
97 | {
|
---|
98 | public:
|
---|
99 | char *_pabLogString;
|
---|
100 | unsigned long _cbLogString;
|
---|
101 |
|
---|
102 | BSMemLoggerBase();
|
---|
103 | ~BSMemLoggerBase();
|
---|
104 |
|
---|
105 | BSMemLoggerBase(const BSMemLoggerBase &l);
|
---|
106 |
|
---|
107 | BSMemLoggerBase& operator=(const BSMemLoggerBase &l);
|
---|
108 |
|
---|
109 | // override virtual method
|
---|
110 | void StoreData(const char *pabData, unsigned long cbData);
|
---|
111 |
|
---|
112 | void Append(const char *pabData, unsigned long cbData);
|
---|
113 | // void Append(const char *pcsz);
|
---|
114 | void Append(const ustring &ustr);
|
---|
115 |
|
---|
116 | void Clear(void);
|
---|
117 |
|
---|
118 | BOOL Store(HINI hini, const char *pszApp, const char *pszKey) const;
|
---|
119 | BOOL Load(HINI hini, const char *pszApp, const char *pszKey);
|
---|
120 | };
|
---|
121 |
|
---|
122 | /*
|
---|
123 | *@@ BSFileLogger:
|
---|
124 | * logger which writes to a file instead of
|
---|
125 | * storing the log entries in memory.
|
---|
126 | *
|
---|
127 | * This needs a file name in the constructor.
|
---|
128 | * The logger still doesn't know what data the
|
---|
129 | * log contains but simply writes it out to
|
---|
130 | * disk.
|
---|
131 | *
|
---|
132 | *@@added V0.9.9 (2001-03-30) [umoeller]
|
---|
133 | *@@changed WarpIN V1.0.14 (2006-11-30) [pr]: added WriteRaw
|
---|
134 | */
|
---|
135 |
|
---|
136 | class BSFileLogger
|
---|
137 | {
|
---|
138 | string _strFileName;
|
---|
139 | int _indent;
|
---|
140 | FILE *_File;
|
---|
141 |
|
---|
142 | public:
|
---|
143 | BSFileLogger(ULONG ulDummy,
|
---|
144 | const char *pcszFilename);
|
---|
145 | virtual ~BSFileLogger();
|
---|
146 |
|
---|
147 | void IncIndent(int i);
|
---|
148 |
|
---|
149 | void WriteV(const char *pcszFormat,
|
---|
150 | va_list arg_ptr);
|
---|
151 |
|
---|
152 | void Write(const char *pcszFormat,
|
---|
153 | ...);
|
---|
154 |
|
---|
155 | // WarpIN V1.0.14 (2006-11-30) [pr]
|
---|
156 | void WriteRawV(const char *pcszFormat,
|
---|
157 | va_list arg_ptr);
|
---|
158 |
|
---|
159 | void WriteRaw(const char *pcszFormat,
|
---|
160 | ...);
|
---|
161 | };
|
---|
162 |
|
---|
163 | /* ******************************************************************
|
---|
164 | *
|
---|
165 | * Package loggers
|
---|
166 | *
|
---|
167 | ********************************************************************/
|
---|
168 |
|
---|
169 | // we define these here because they are used both in fe_script.h
|
---|
170 | // and fe_package.h
|
---|
171 |
|
---|
172 | /*
|
---|
173 | *@@ BSRequiresLogger:
|
---|
174 | * logger used in FEPackageBase to
|
---|
175 | * store five- or six-part package IDs
|
---|
176 | * which are required by a package.
|
---|
177 | *
|
---|
178 | *@@added V0.9.1 (2000-01-07) [umoeller]
|
---|
179 | */
|
---|
180 |
|
---|
181 | class BSRequiresIDsLogger : public BSMemLoggerBase { };
|
---|
182 |
|
---|
183 | /*
|
---|
184 | *@@ BSRequiresStringsLogger:
|
---|
185 | * logger used in FEArcPackagePck to store
|
---|
186 | * the REQUIRES attributes exactly as they
|
---|
187 | * are found in the archive. This is translated
|
---|
188 | * later after all packages have been parsed.
|
---|
189 | *
|
---|
190 | *@@added V0.9.1 (2000-01-07) [umoeller]
|
---|
191 | */
|
---|
192 |
|
---|
193 | class BSRequiresStringsLogger : public BSMemLoggerBase { };
|
---|
194 |
|
---|
195 | /*
|
---|
196 | *@@ BSCreatedDirsLogger:
|
---|
197 | * logger used in FEArcPackagePck to store
|
---|
198 | * the directories that were actually created
|
---|
199 | * during the install. This is appended to
|
---|
200 | * while files are being unpacked.
|
---|
201 | *
|
---|
202 | *@@added V0.9.20 (2002-07-22) [umoeller]
|
---|
203 | */
|
---|
204 |
|
---|
205 | class BSCreatedDirsLogger : public BSMemLoggerBase { };
|
---|
206 |
|
---|
207 | #endif
|
---|
208 |
|
---|
209 |
|
---|