HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_UniversalLogSink.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_UniversalLogSink.h ( FS Library, C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __UT_UniversalLogSink__
13 #define __UT_UniversalLogSink__
14 
15 #include "UT_API.h"
16 #include "UT_Function.h"
17 #include "UT_Lock.h"
18 #include "UT_SharedPtr.h"
19 #include "UT_StringSet.h"
20 #include "UT_UniversalLogEntry.h"
21 
22 class UT_StringArray;
23 class UT_StringHolder;
26 
27 /// This class exists to amalgamate logging information from a variety of
28 /// sources (UT_UniversalLogSource objects). Log entries can be fetched and
29 /// filtered to present the user with just the logging they are interested in.
31 {
32 public:
35 
37  virtual ~UT_UniversalLogSink();
38 
39  /// Each sink creates its own source objects, and can only have one source
40  /// of any given type.
41  void connect(const UT_StringHolder &source_name);
42  void disconnect(const UT_StringHolder &source_name);
43  void disconnectAll();
44  void getConnectedSourceNames(UT_StringArray &source_names);
45 
47  { myLogEntryFilterCallback = callback; }
48 
49  /// Record a message from a log source.
50  void log(const UT_UniversalLogEntry &entry);
51 
52 protected:
53  virtual void doLog(const UT_UniversalLogEntry &entry) = 0;
54 
55 private:
56  UT_StringSet mySources;
57  UT_Lock mySourcesLock;
58  LogEntryFilterCallback myLogEntryFilterCallback;
59 };
60 
61 // Functions related to the default in memory and file logs.
62 UT_API bool
64 UT_API bool
66 UT_API bool
67 UTisDefaultLogInMemorySource(const UT_StringRef &source_name);
68 UT_API bool
69 UTisDefaultLogFileSource(const UT_StringRef &source_name);
71 UTgetDefaultLogInMemorySink(bool create_from_env, bool force_create);
73 UTgetDefaultLogFileSink(bool create);
74 
75 #endif
76 
UT_API bool UTisDefaultLogInMemorySource(const UT_StringRef &source_name)
UT_API bool UThasAnyDefaultLogInMemorySources()
#define UT_API
Definition: UT_API.h:14
UT_API bool UTisDefaultLogFileSource(const UT_StringRef &source_name)
UT_Function< bool(const UT_UniversalLogEntry &)> LogEntryFilterCallback
void setFilterEntryCallback(const LogEntryFilterCallback &callback)
UT_API const UT_SharedPtr< UT_UniversalLogInMemorySink > & UTgetDefaultLogInMemorySink(bool create_from_env, bool force_create)
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:36
UT_API bool UThasAnyDefaultLogFileSources()
std::function< T > UT_Function
Definition: UT_Function.h:37
UT_API const UT_SharedPtr< UT_UniversalLogFileSink > & UTgetDefaultLogFileSink(bool create)
OIIO_FORCEINLINE T log(const T &v)
Definition: simd.h:7688
Simple object to hold the data associated with a single log entry event.