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

Last change on this file since 250 was 250, checked in by umoeller, 23 years ago

Build updates, moved files from warpin.

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