diff options
author | Jacek Antonelli | 2008-08-15 23:44:50 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:50 -0500 |
commit | 89fe5dab825a62a0e3fd8d248cbc91c65eb2a426 (patch) | |
tree | bcff14b7888d04a2fec799c59369f6095224bd08 /linden/indra/llcommon/llerrorcontrol.h | |
parent | Second Life viewer sources 1.13.3.2 (diff) | |
download | meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.zip meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.gz meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.bz2 meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.xz |
Second Life viewer sources 1.14.0.0
Diffstat (limited to 'linden/indra/llcommon/llerrorcontrol.h')
-rw-r--r-- | linden/indra/llcommon/llerrorcontrol.h | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/linden/indra/llcommon/llerrorcontrol.h b/linden/indra/llcommon/llerrorcontrol.h new file mode 100644 index 0000000..f2c8755 --- /dev/null +++ b/linden/indra/llcommon/llerrorcontrol.h | |||
@@ -0,0 +1,142 @@ | |||
1 | /** | ||
2 | * @file llerrorcontrol.h | ||
3 | * @date December 2006 | ||
4 | * @brief error message system control | ||
5 | * | ||
6 | * Copyright (c) 2007-2007, Linden Research, Inc. | ||
7 | * | ||
8 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
9 | * to you under the terms of the GNU General Public License, version 2.0 | ||
10 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
11 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
12 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
13 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
14 | * | ||
15 | * There are special exceptions to the terms and conditions of the GPL as | ||
16 | * it is applied to this Source Code. View the full text of the exception | ||
17 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
18 | * online at http://secondlife.com/developers/opensource/flossexception | ||
19 | * | ||
20 | * By copying, modifying or distributing this software, you acknowledge | ||
21 | * that you have read and understood your obligations described above, | ||
22 | * and agree to abide by those obligations. | ||
23 | * | ||
24 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
25 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
26 | * COMPLETENESS OR PERFORMANCE. | ||
27 | */ | ||
28 | |||
29 | #ifndef LL_LLERRORCONTROL_H | ||
30 | #define LL_LLERRORCONTROL_H | ||
31 | |||
32 | #include "llerror.h" | ||
33 | |||
34 | #include <string> | ||
35 | |||
36 | class LLFixedBuffer; | ||
37 | class LLSD; | ||
38 | |||
39 | /* | ||
40 | This is the part of the LLError namespace that manages the messages | ||
41 | produced by the logging. The logging support is defined in llerror.h. | ||
42 | Most files do not need to include this. | ||
43 | |||
44 | These implementations are in llerror.cpp. | ||
45 | */ | ||
46 | |||
47 | |||
48 | namespace LLError | ||
49 | { | ||
50 | void initForServer(const std::string& identity); | ||
51 | // resets all logging settings to defaults needed by server processes | ||
52 | // logs to stderr, syslog, and windows debug log | ||
53 | // the identity string is used for in the syslog | ||
54 | |||
55 | void initForApplication(const std::string& dir); | ||
56 | // resets all logging settings to defaults needed by applicaitons | ||
57 | // logs to stderr and windows debug log | ||
58 | // sets up log configuration from the file logcontrol.xml in dir | ||
59 | |||
60 | |||
61 | /* | ||
62 | Settings that control what is logged. | ||
63 | Setting a level means log messages at that level or above. | ||
64 | */ | ||
65 | |||
66 | void setPrintLocation(bool); | ||
67 | void setDefaultLevel(LLError::ELevel); | ||
68 | void setFunctionLevel(const std::string& function_name, LLError::ELevel); | ||
69 | void setClassLevel(const std::string& class_name, LLError::ELevel); | ||
70 | void setFileLevel(const std::string& file_name, LLError::ELevel); | ||
71 | |||
72 | void configure(const LLSD&); | ||
73 | // the LLSD can configure all of the settings | ||
74 | // usually read automatically from the live errorlog.xml file | ||
75 | |||
76 | |||
77 | /* | ||
78 | Control functions. | ||
79 | */ | ||
80 | |||
81 | typedef void (*FatalFunction)(const std::string& message); | ||
82 | void crashAndLoop(const std::string& message); | ||
83 | // Default fatal funtion: divides by zero and loops forever | ||
84 | |||
85 | void setFatalFunction(FatalFunction); | ||
86 | // The fatal function will be called when an message of LEVEL_ERROR | ||
87 | // is logged. Note: supressing a LEVEL_ERROR message from being logged | ||
88 | // (by, for example, setting a class level to LEVEL_NONE), will keep | ||
89 | // the that message from causing the fatal funciton to be invoked. | ||
90 | |||
91 | typedef std::string (*TimeFunction)(); | ||
92 | std::string utcTime(); | ||
93 | |||
94 | void setTimeFunction(TimeFunction); | ||
95 | // The function is use to return the current time, formatted for | ||
96 | // display by those error recorders that want the time included. | ||
97 | |||
98 | |||
99 | |||
100 | class Recorder | ||
101 | { | ||
102 | // An object that handles the actual output or error messages. | ||
103 | public: | ||
104 | virtual ~Recorder(); | ||
105 | |||
106 | virtual void recordMessage(LLError::ELevel, const std::string& message) = 0; | ||
107 | // use the level for better display, not for filtering | ||
108 | |||
109 | virtual bool wantsTime(); // default returns false | ||
110 | // override and return true if the recorder wants the time string | ||
111 | // included in the text of the message | ||
112 | }; | ||
113 | |||
114 | void addRecorder(Recorder*); | ||
115 | void removeRecorder(Recorder*); | ||
116 | // each error message is passed to each recorder via recordMessage() | ||
117 | |||
118 | void logToFile(const std::string& filename); | ||
119 | void logToFixedBuffer(LLFixedBuffer*); | ||
120 | // Utilities to add recorders for logging to a file or a fixed buffer | ||
121 | // A second call to the same function will remove the logger added | ||
122 | // with the first. | ||
123 | // Passing the empty string or NULL to just removes any prior. | ||
124 | std::string logFileName(); | ||
125 | // returns name of current logging file, empty string if none | ||
126 | |||
127 | |||
128 | /* | ||
129 | Utilities for use by the unit tests of LLError itself. | ||
130 | */ | ||
131 | |||
132 | class Settings; | ||
133 | Settings* saveAndResetSettings(); | ||
134 | void restoreSettings(Settings *); | ||
135 | |||
136 | std::string abbreviateFile(const std::string& filePath); | ||
137 | int shouldLogCallCount(); | ||
138 | |||
139 | }; | ||
140 | |||
141 | #endif // LL_LLERRORCONTROL_H | ||
142 | |||