HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_UniversalLogEntry.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_UniversalLogEntry.h ( FS Library, C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __UT_UniversalLogEntry__
13 #define __UT_UniversalLogEntry__
14 
15 #include "UT_API.h"
16 #include "UT_Array.h"
17 #include "UT_Date.h"
18 #include "UT_Error.h"
19 #include "UT_IntrusivePtr.h"
20 #include "UT_SourceLocation.h"
21 #include "UT_StringHolder.h"
22 #include <SYS/SYS_Hash.h>
23 #include <SYS/SYS_Math.h>
25 #include <SYS/SYS_Time.h>
26 
27 class UT_JSONParser;
28 class UT_JSONWriter;
29 
31  public UT_IntrusiveRefCounter<UT_UniversalLogExternalInfo>
32 {
33 public:
35  : myProcessId(0)
36  { }
37 
39  {
41  SYShashCombine(h, myIdentifier.hash());
42  SYShashCombine(h, myCommandLine.hash());
43  SYShashCombine(h, SYSwang_inthash(myProcessId));
44 
45  return h;
46  }
47 
52 };
55 
56 /// Simple object to hold the data associated with a single log entry event.
58 {
59 public:
63  const UT_StringHolder &source_context = UT_StringHolder::theEmptyString,
65  int verbosity = 0,
66  const UT_SourceLocation &source_code_location = UT_SourceLocation(),
67  UT_UniversalLogExternalInfoHandle external_info =
69  : mySourceName(source_name),
70  myMessage(message),
71  mySourceContext(source_context),
72  mySourceCodeLocation(source_code_location),
73  myErrorSeverity(severity),
74  myVerbosity(verbosity),
75  myTime(SYStime() - theStartTime + theStartTimeSinceEpoch),
76  myThreadId(SYSgetSTID()),
77  myExternalInfo(external_info)
78  { }
79 
80  /// The natural order of log messages is chronological.
81  bool operator<(const UT_UniversalLogEntry &other) const
82  {
83  return myTime < other.myTime;
84  }
85 
87  {
88  return sizeof(*this) +
89  mySourceName.length() +
90  myMessage.length() +
91  mySourceContext.length() +
92  mySourceCodeLocation.getMemoryUsage(false);
93  }
94 
96  {
97  SYS_HashType h = mySourceName.hash();
98  SYShashCombine(h, myMessage.hash());
99  SYShashCombine(h, mySourceContext.hash());
100  SYShashCombine(h, mySourceCodeLocation.source().hash());
101  SYShashCombine(h, SYSwang_inthash(mySourceCodeLocation.line()));
102  SYShashCombine(h, SYSwang_inthash(mySourceCodeLocation.columnStart()));
103  SYShashCombine(h, SYSwang_inthash(mySourceCodeLocation.columnEnd()));
104  SYShashCombine(h, SYSwang_inthash(myErrorSeverity));
105  SYShashCombine(h, SYSwang_inthash(myVerbosity));
106  SYShashCombine(h, SYSreal_hash(myTime));
107  SYShashCombine(h, SYSwang_inthash(myThreadId));
108  if (myExternalInfo)
109  SYShashCombine(h, myExternalInfo->hash());
110 
111  return h;
112  }
113 
114  static bool save(UT_JSONWriter &w,
115  const UT_Array<UT_UniversalLogEntry> &log_entries);
116  static bool load(UT_JSONParser &p,
117  UT_Array<UT_UniversalLogEntry> &log_entries);
118 
130 };
132 
133 #endif
GLuint GLsizei const GLchar * message
Definition: glcorearb.h:2542
unsigned hash() const
int myThreadId
UT_StringHolder mySourceName
UT_UniversalLogEntry(const UT_StringHolder &source_name=UT_StringHolder::theEmptyString, const UT_StringHolder &message=UT_StringHolder::theEmptyString, const UT_StringHolder &source_context=UT_StringHolder::theEmptyString, UT_ErrorSeverity severity=UT_ERROR_NONE, int verbosity=0, const UT_SourceLocation &source_code_location=UT_SourceLocation(), UT_UniversalLogExternalInfoHandle external_info=UT_UniversalLogExternalInfoHandle())
SYS_HashType hash() const
int64 exint
Definition: SYS_Types.h:125
std::size_t SYS_HashType
Define the type for hash values.
Definition: SYS_Hash.h:19
UT_ErrorSeverity
Definition: UT_Error.h:25
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:88
#define UT_API
Definition: UT_API.h:14
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:35
A reference counter base class for use with UT_IntrusivePtr.
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
static const UT_StringHolder theEmptyString
int myVerbosity
GLfloat GLfloat p
Definition: glew.h:16656
GLenum GLenum severity
Definition: glcorearb.h:2538
SYS_API fpreal SYStime()
UT_Array< UT_UniversalLogEntry > UT_UniversalLogEntryArray
UT_StringHolder mySourceContext
UT_UniversalLogExternalInfoHandle myExternalInfo
exint getMemoryUsage() const
UT_SourceLocation mySourceCodeLocation
UT_StringHolder myMessage
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2001
SYS_API int SYSgetSTID()
fpreal64 fpreal
Definition: SYS_Types.h:277
static fpreal theStartTime
UT_IntrusivePtr< UT_UniversalLogExternalInfo > UT_UniversalLogExternalInfoHandle
fpreal myTime
static fpreal theStartTimeSinceEpoch
bool operator<(const UT_UniversalLogEntry &other) const
The natural order of log messages is chronological.
Simple object to hold the data associated with a single log entry event.
UT_ErrorSeverity myErrorSeverity