source: trunk/include/cppbase/bs_logger.h@ 327

Last change on this file since 327 was 312, checked in by pr, 19 years ago

Added Clear method to BSMemLoggerBase

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 6.7 KB
Line 
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-2002 Ulrich M”ller.
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 */
134
135 class BSFileLogger
136 {
137 string _strFileName;
138 int _indent;
139 FILE *_File;
140
141 public:
142 BSFileLogger(ULONG ulDummy,
143 const char *pcszFilename);
144 virtual ~BSFileLogger();
145
146 void IncIndent(int i);
147
148 void WriteV(const char *pcszFormat,
149 va_list arg_ptr);
150
151 void Write(const char *pcszFormat,
152 ...);
153 };
154
155 /* ******************************************************************
156 *
157 * Package loggers
158 *
159 ********************************************************************/
160
161 // we define these here because they are used both in fe_script.h
162 // and fe_package.h
163
164 /*
165 *@@ BSRequiresLogger:
166 * logger used in FEPackageBase to
167 * store five- or six-part package IDs
168 * which are required by a package.
169 *
170 *@@added V0.9.1 (2000-01-07) [umoeller]
171 */
172
173 class BSRequiresIDsLogger : public BSMemLoggerBase { };
174
175 /*
176 *@@ BSRequiresStringsLogger:
177 * logger used in FEArcPackagePck to store
178 * the REQUIRES attributes exactly as they
179 * are found in the archive. This is translated
180 * later after all packages have been parsed.
181 *
182 *@@added V0.9.1 (2000-01-07) [umoeller]
183 */
184
185 class BSRequiresStringsLogger : public BSMemLoggerBase { };
186
187 /*
188 *@@ BSCreatedDirsLogger:
189 * logger used in FEArcPackagePck to store
190 * the directories that were actually created
191 * during the install. This is appended to
192 * while files are being unpacked.
193 *
194 *@@added V0.9.20 (2002-07-22) [umoeller]
195 */
196
197 class BSCreatedDirsLogger : public BSMemLoggerBase { };
198
199#endif
200
201
Note: See TracBrowser for help on using the repository browser.