/src/resiprocate/rutil/Subsystem.hxx
Line | Count | Source |
1 | | #if !defined(RESIP_SUBSYSTEM_HXX) |
2 | | #define RESIP_SUBSYSTEM_HXX |
3 | | |
4 | | #include <iostream> |
5 | | #include "rutil/Data.hxx" |
6 | | #include "rutil/Log.hxx" |
7 | | |
8 | | namespace resip |
9 | | { |
10 | | |
11 | | /** |
12 | | @brief Class used to specify what sub-system given sections of code belong |
13 | | to, for use by the logging system. |
14 | | |
15 | | @note The logging macros defined in Logger.hxx assume that the preprocessor |
16 | | macro RESIPROCATE_SUBSYSTEM is defined to an instance of this class. The |
17 | | logging macro uses this object to determine what logging level should be |
18 | | used, and what sub-system the logging statement should come from. So, in |
19 | | your code you might do something like the following: |
20 | | |
21 | | @code |
22 | | #define RESIPROCATE_SUBSYSTEM Subsystem::APP |
23 | | //... |
24 | | void doStuff() |
25 | | { |
26 | | DebugLog(<< "Doing some stuff..."); |
27 | | } |
28 | | @endcode |
29 | | |
30 | | This would cause your log statement to be marked as coming from |
31 | | Subsystem::APP. |
32 | | */ |
33 | | class Subsystem |
34 | | { |
35 | | public: |
36 | | // Add new systems below |
37 | | static Subsystem APP; |
38 | | static Subsystem CONTENTS; |
39 | | static Subsystem DNS; |
40 | | static Subsystem DUM; |
41 | | static Subsystem EEP; |
42 | | static Subsystem MEDIA; |
43 | | static Subsystem NONE; // default subsystem |
44 | | static Subsystem PRESENCE; |
45 | | static Subsystem PYTHON; |
46 | | static Subsystem SDP; |
47 | | static Subsystem SIP; // SIP Stack / Parser |
48 | | static Subsystem TEST; |
49 | | static Subsystem TRANSACTION; |
50 | | static Subsystem TRANSPORT; |
51 | | static Subsystem STATS; |
52 | | static Subsystem REPRO; |
53 | | static Subsystem QPIDPROTON; |
54 | | |
55 | | const Data& getSubsystem() const; |
56 | 3.62M | Log::Level getLevel() const { return mLevel; } |
57 | 0 | void setLevel(Log::Level level) { mLevel = level; } |
58 | | protected: |
59 | 34 | explicit Subsystem(const char* rhs) : mSubsystem(rhs), mLevel(Log::None) {}; |
60 | 0 | explicit Subsystem(const Data& rhs) : mSubsystem(rhs), mLevel(Log::None) {}; |
61 | | Subsystem& operator=(const Data& rhs); |
62 | | |
63 | | Data mSubsystem; |
64 | | Log::Level mLevel; |
65 | | |
66 | | friend EncodeStream& operator<<(EncodeStream& strm, const Subsystem& ss); |
67 | | }; |
68 | | |
69 | | EncodeStream& operator<<(EncodeStream& strm, const Subsystem& ss); |
70 | | |
71 | | |
72 | | // in order to have subsystems in your application, subclass from this class |
73 | | /* |
74 | | #include "rutil/Data.hxx" |
75 | | #include "rutil/Subsystem.hxx" |
76 | | |
77 | | namespace MyNamespace |
78 | | { |
79 | | |
80 | | class Subsystem : public resip::Subsystem |
81 | | { |
82 | | public: |
83 | | // Add new systems below |
84 | | static const Subsystem SPECIAL_SUBSYSTEM; |
85 | | |
86 | | private: |
87 | | explicit Subsystem(const char* rhs) : resip::Subsystem(rhs) {}; |
88 | | explicit Subsystem(const resip::Data& rhs); |
89 | | Subsystem& operator=(const resip::Data& rhs); |
90 | | }; |
91 | | |
92 | | } |
93 | | */ |
94 | | |
95 | | } |
96 | | |
97 | | #endif |
98 | | |
99 | | /* ==================================================================== |
100 | | * The Vovida Software License, Version 1.0 |
101 | | * |
102 | | * Copyright (c) 2000-2005 |
103 | | * |
104 | | * Redistribution and use in source and binary forms, with or without |
105 | | * modification, are permitted provided that the following conditions |
106 | | * are met: |
107 | | * |
108 | | * 1. Redistributions of source code must retain the above copyright |
109 | | * notice, this list of conditions and the following disclaimer. |
110 | | * |
111 | | * 2. Redistributions in binary form must reproduce the above copyright |
112 | | * notice, this list of conditions and the following disclaimer in |
113 | | * the documentation and/or other materials provided with the |
114 | | * distribution. |
115 | | * |
116 | | * 3. The names "VOCAL", "Vovida Open Communication Application Library", |
117 | | * and "Vovida Open Communication Application Library (VOCAL)" must |
118 | | * not be used to endorse or promote products derived from this |
119 | | * software without prior written permission. For written |
120 | | * permission, please contact vocal@vovida.org. |
121 | | * |
122 | | * 4. Products derived from this software may not be called "VOCAL", nor |
123 | | * may "VOCAL" appear in their name, without prior written |
124 | | * permission of Vovida Networks, Inc. |
125 | | * |
126 | | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED |
127 | | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
128 | | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND |
129 | | * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA |
130 | | * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES |
131 | | * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, |
132 | | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
133 | | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
134 | | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
135 | | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
136 | | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE |
137 | | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
138 | | * DAMAGE. |
139 | | * |
140 | | * ==================================================================== |
141 | | * |
142 | | * This software consists of voluntary contributions made by Vovida |
143 | | * Networks, Inc. and many individuals on behalf of Vovida Networks, |
144 | | * Inc. For more information on Vovida Networks, Inc., please see |
145 | | * <http://www.vovida.org/>. |
146 | | * |
147 | | */ |