DataDirector API
DDD_Log.h
Go to the documentation of this file.
1 #ifndef DDD_LOG_H_
2 #define DDD_LOG_H_
3 
4 /*! \file DDD_Log.h
5 
6 
7  \par Copyright Information
8 
9  Copyright (c) 2012 The DiSTI Corporation.<br>
10  11301 Corporate Blvd; Suite 100<br>
11  Orlando, Florida 32817<br>
12  USA<br>
13  <br>
14  All rights reserved.<br>
15 
16  This Software contains proprietary trade secrets of DiSTI and may not be
17 reproduced, in whole or part, in any form, or by any means of electronic,
18 mechanical, or otherwise, without the written permission of DiSTI. Said
19 permission may be derived through the purchase of applicable DiSTI product
20 licenses which detail the distribution rights of this content and any
21 Derivative Works based on this or other copyrighted DiSTI Software.
22 
23  NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
24 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
25 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
26 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
27 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
28 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
29 
30  LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
31 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
32 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
33 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
34 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
35 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBLITY
36 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
37 EXCEED FIVE DOLLARS (US$5.00).
38 
39  The aforementioned terms and restrictions are governed by the laws of the
40 State of Florida and the United States of America.
41 
42 */
43 
44 #include "DDD_Include.h"
45 #include "dynamic_ptr_array.h"
46 #include <string>
47 
48 namespace disti
49 {
50 
51 class DDD_LogObserver;
52 
53 /** \brief Simple container for log entries.
54  * \note Members aren't meant to be mutable once instantiated. */
55 class DDD_EXPORT DDD_LogEntry
56 {
57 public:
58  /** Level of importance. */
59  enum LogLevel
60  {
61  LOG_DEBUG,
62  LOG_INFO,
63  LOG_WARNING,
64  LOG_ERROR
65  };
66 
67  /** Constructor.
68  * \param entryStr The logged entry string
69  * \param level The entry's level of importance
70  */
71  DDD_LogEntry(const std::string& entryStr, LogLevel level = LOG_INFO);
72 
73  /** Entry Level
74  * \return entry log level
75  */
76  LogLevel Level() const { return _level; }
77 
78  /** Entry String
79  * \return entry string
80  */
81  std::string EntryStr() const { return _entryStr; }
82 
83  /** Static helper for converting Log Level to a string
84  * \param level The logged entry level
85  */
86  static const char *LogLevelToString(LogLevel level);
87 
88 private:
89  // The reasoning behind not having mutators for these members is that this class's sole purpose
90  // is only to conveniently transport these to observers.
91 
92  std::string _entryStr; /**< The log message string */
93  LogLevel _level; /**< The level of the message */
94 };
95 
96 
97 
98 /** \brief Central logging class. Handles all of the logic for registering/unregistering observers, accepting log
99  entries, and notifying log observers. */
100 class DDD_EXPORT DDD_Log
101 {
102 public:
104 
105  /** Destructor. */
106  virtual ~DDD_Log();
107 
108  /** Convenient LogEntry() wrapper for logging general information.
109  * \param entry The logged entry string
110  */
111  void LogDebug(const char* entry);
112 
113  /** Convenient LogEntry() wrapper for logging general information.
114  * \param entry The logged entry string
115  */
116  void LogInfo(const char* entry);
117 
118  /** Convenient LogEntry() wrapper for logging warnings.
119  * \param entry The logged entry string
120  */
121  void LogWarning(const char* entry);
122 
123  /** Convenient LogEntry() wrapper for logging errors.
124  * \param entry The logged entry string
125  */
126  void LogError(const char* entry);
127 
128  /** Log Entry to log observers. This method notifies every log observer.
129  * \param entry The logged entry string
130  * \param level The logged entry level
131  */
132  void LogEntry(const char *entry, DDD_LogEntry::LogLevel level);
133 
134  /** Add Log Observer
135  * \param observer Pointer to a LogObserver (must not be NULL)
136  */
137  void AddObserver( DDD_LogObserver *observer );
138 
139  /** Remove Log Observer
140  * \param observer Pointer to a LogObserver
141  */
142  void RemoveObserver( DDD_LogObserver *observer );
143 
144  /** Singleton interface
145  * \return reference to static DDD_LogFacade object
146  */
147  static DDD_Log& Instance();
148 
149  /** Shutdown logger; simply clears observers list */
150  void Shutdown();
151 
152 private:
153  /** Constructor. This has been made private to enforce singleton interface. */
154  DDD_Log();
155 
156 private:
157  LogObserverList _observers; /**< List of log observers */
158 };
159 
160 } // end of namespace disti
161 
162 #endif
163 
LogLevel Level() const
Definition: DDD_Log.h:76
LogLevel
Definition: DDD_Log.h:59
std::string EntryStr() const
Definition: DDD_Log.h:81
Central logging class. Handles all of the logic for registering/unregistering observers, accepting log entries, and notifying log observers.
Definition: DDD_Log.h:100
Simple container for log entries.
Definition: DDD_Log.h:55
The disti::DynamicPtrArray class. A templated array of objects pointers capable of dynamically growin...
Abstract base class for log observers.
Definition: DDD_LogObserver.h:52
Definition: AttributeChangedEmitter.h:46