aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcommon/llerrorstream.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llcommon/llerrorstream.h
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llcommon/llerrorstream.h')
-rw-r--r--linden/indra/llcommon/llerrorstream.h126
1 files changed, 126 insertions, 0 deletions
diff --git a/linden/indra/llcommon/llerrorstream.h b/linden/indra/llcommon/llerrorstream.h
new file mode 100644
index 0000000..4028583
--- /dev/null
+++ b/linden/indra/llcommon/llerrorstream.h
@@ -0,0 +1,126 @@
1/**
2 * @file llerrorstream.h
3 * @brief Declaration of c++ log straming.
4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#ifndef LL_LLERRORSTREAM_H
29#define LL_LLERRORSTREAM_H
30
31// Usage:
32// LLErrorStream gErrorStream(gErrorBuffer);
33//
34// gErrorStream << debug << "This is a debug message" << endl;
35//
36// gErrorStream << fatal << "This message will cause a crash!" << endl;
37
38#include <iostream>
39#include "llerrorbuffer.h"
40#include "stdtypes.h"
41
42class LLFixedBuffer;
43
44class LLErrorStream : public std::ostream
45{
46 public:
47 LLErrorStream(LLErrorBuffer *eb);
48
49 // Specify error levels-- Use LLErrorBuffer::ELevel instead
50 enum ELevel
51 {
52 DEBUG = 0,
53 INFO = 1,
54 WARN = 2,
55 FATAL = 3,
56 NONE = 4 // Don't log anything
57 };
58
59 LLErrorBuffer *mErrorBuffer;
60
61 // This is used to specify if we need to merge the DebugMask
62 // or replace it
63 enum EControl
64 {
65 REPLACE = 0,
66 MERGE = 1
67 };
68
69 void setDebugMask(U32 mask) { mDebugMask = mask; }
70 void mergeDebugMask(U32 mask) { mDebugMask |= mask; }
71 U32 getDebugMask() { return mDebugMask; }
72 void setDebugFlag(U32 flag) { mDebugMask |= flag; }
73 void clearDebugFlag(U32 flag) { mDebugMask &= ~flag; }
74 BOOL setFile(const char *path) { return mErrorBuffer->setFile(path); }
75 void closeFile() { mErrorBuffer->closeFile(); }
76 const char *getFilename() const { return mErrorBuffer->getFilename(); }
77 void setFixedBuffer(LLFixedBuffer *b) { mErrorBuffer->setFixedBuffer(b); }
78 void setErrorLevel(const LLErrorBuffer::ELevel l) { mErrorBuffer->setLevel(l); }
79 LLErrorBuffer::ELevel getErrorLevel() { return mErrorBuffer->getLevel(); }
80 void mergeErrorLevel(const LLErrorBuffer::ELevel l) { mErrorBuffer->mergeLevel(l); }
81 void setError() { mKill = TRUE; };
82 void crashOnError(std::ostringstream &ss, LLErrorBuffer::ELevel l);
83
84 BOOL isEnabledFor(const LLErrorBuffer::ELevel l);
85 BOOL isEnabledFor(const LLErrorBuffer::ELevel l, const U32 type);
86
87
88 void mergeLevel(const LLErrorBuffer::ELevel l) { mErrorBuffer->mergeLevel(l); }
89
90 void setPrintLocation(BOOL b) { mPrintLocation = b; }
91 BOOL getPrintLocation() { return mPrintLocation; }
92
93 void setElevatedRemote(BOOL b) { mErrorBuffer->setElevatedRemote(b); }
94 void setUTCTimestamp(BOOL utc) { mErrorBuffer->setUTCTimestamp(utc); }
95
96 // Deprecated
97 void setLevel(const ELevel l) { setErrorLevel(ELevelToBufferELevel(l)); }
98 ELevel getLevel() { return BufferELevelToELevel(getErrorLevel()); }
99 void mergeLevel(const ELevel l) { mergeErrorLevel(ELevelToBufferELevel(l)); }
100
101
102 // Backwards compatilibity cruft. Should be removed
103 void mergeTime(BOOL b) { } // NOP
104 void mergeLocation(BOOL b) { } // NOP
105 void setTime(BOOL b) { } // NOP
106 char *getTime() { return ""; } // NOP
107
108 typedef void(*LLErrorCallback)(const std::string &error_string);
109 void setErrorCallback(LLErrorCallback callback) {mErrorCallback = callback;}
110
111private:
112 // This maintains the existing ELevel interface, but new code should use
113 // LLErrorBuffer::ELevel instead.
114 LLErrorBuffer::ELevel ELevelToBufferELevel(const ELevel l);
115 ELevel BufferELevelToELevel(const LLErrorBuffer::ELevel l);
116 U32 mDebugMask; // Mask for debugst() output
117
118 BOOL mPrintLocation;
119
120 S32 mSafeDepth; // Counter so we can safely do recursive calls, 0 means we're OK
121 BOOL mKill;
122 LLErrorCallback mErrorCallback;
123};
124
125
126#endif // LL_LLERRORSTREAM_H