• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ------------------------------------------------------------------
2  * Copyright (C) 1998-2009 PacketVideo
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13  * express or implied.
14  * See the License for the specific language governing permissions
15  * and limitations under the License.
16  * -------------------------------------------------------------------
17  */
18 #ifndef PVLOGGER_REGISTRY_H_INCLUDED
19 #define PVLOGGER_REGISTRY_H_INCLUDED
20 
21 #ifndef PVLOGGER_H_INCLUDED
22 #include "pvlogger.h"
23 #endif
24 
25 #ifndef OSCL_TAGTREE_H_INCLUDED
26 #include "oscl_tagtree.h"
27 #endif
28 
29 /**
30  * Class: PVLoggerRegistry
31  *
32  * PVLoggerRegistry class, maintains a repository of all the loggers, along with
33  * their associated tags, in a tag tree. Any request for a log control point is
34  * serviced by this class.
35  *
36  * Memory Ownership: Creates log control points for each tag, and holds these
37  * pointers in the tag tree. PVLogger registry is responsible for calling the
38  * destructor on each of these loggers.
39  *
40  */
41 
42 class PVLoggerRegistry
43 {
44     public:
45 
46         typedef PVLogger::log_level_type log_level_type;
47         typedef PVLogger::alloc_type alloc_type;
48 
49         /**
50          * Get the logger registry.  There is only one logger
51          * registry instance per thread.
52          */
53         OSCL_IMPORT_REF static PVLoggerRegistry* GetPVLoggerRegistry();
54 
55         /**
56          * PVLoggerRegistry Constructor
57          *
58          */
59         OSCL_IMPORT_REF PVLoggerRegistry();
60 
61         /**
62          * PVLoggerRegistry Destructor
63          *
64          */
65         OSCL_IMPORT_REF virtual ~PVLoggerRegistry();
66 
67         /**
68          * PVLoggerRegistry method to get access to a logging control point, associated with
69          * a tag. In case the logger for this tag does not exist, it is created afresh, else
70          * pointer to the existing one is returned.
71          *
72          * @param inputTag   logger tag, viz. "x.y.z"
73          * @param level      log level associated with the logging control point
74          *
75          * @param oAppenderInheritance
76          *
77          * @return PVLogger<Alloc, TheLock>* Pointer to the logging control point
78          */
79         OSCL_IMPORT_REF PVLogger *GetPVLoggerObject(const char* tagIn);
80 
81         /**
82          * This method creates a log control point, with specified tag, and level
83          *
84          * @param inputTag   logger tag, viz. "x.y.z"
85          * @param level      log level associated with the logging control point
86          *
87          * @param oAppenderInheritance
88          *
89          * @return PVLogger<alloc_type, TheLock>* Pointer to the logging control point
90          */
91         OSCL_IMPORT_REF PVLogger *CreatePVLogger(const char* tagIn, log_level_type level, bool oAppenderInheritance);
92 
93         /**
94          * This method propagates the log level to all the descendents of the node,
95          * with a specified tag.
96          *
97          * @param tagIn      logger tag, viz. "x.y.z"
98          * @param level      log level associated with the logging control point
99          *
100          * @return           true on success, else false.
101          */
102         OSCL_IMPORT_REF bool SetNodeLogLevelExplicit(char* tagIn, log_level_type level);
103 
104         /**
105          * This method recursively propagates the log level to all the descendents,
106          * of a node.
107          *
108          * @param node       Node ptr, associated with a logger, from the tag tree.
109          * @param level      log level associated with the logging control point
110          *
111          * @return           NONE
112          */
113         OSCL_IMPORT_REF void SetNodeLogLevelExplicit(Oscl_TagTree<PVLogger*, alloc_type>::node_type* node, log_level_type level);
114 
115     private:
116 #if (PVLOGGER_ENABLE)
117         Oscl_TAlloc<PVLogger, alloc_type> _pvloggerAlloc;
118         Oscl_TagTree<PVLogger*, alloc_type> _loggerTree;
119 #endif
120 };
121 
122 #endif // PVLOGGER_REGISTRY_H_INCLUDED
123 
124