3 //=============================================================================
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
9 //=============================================================================
11 // These need to go outside of the #ifdef to avoid problems with
12 // circular dependencies...
14 #include "ace/Log_Priority.h"
16 #ifndef ACE_LOG_RECORD_H
17 #define ACE_LOG_RECORD_H
18 #include /**/ "ace/pre.h"
20 #include /**/ "ace/ACE_export.h"
22 #if !defined (ACE_LACKS_PRAGMA_ONCE)
24 #endif /* ACE_LACKS_PRAGMA_ONCE */
26 #include "ace/Default_Constants.h"
27 #include "ace/Basic_Types.h"
28 #include "ace/iosfwd.h"
30 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
33 class ACE_Log_Category_TSS
;
35 /// Defines the structure of an ACE logging record.
36 class ACE_Export ACE_Log_Record
41 /// Maximum size of a logging message.
42 MAXLOGMSGLEN
= ACE_MAXLOGMSGLEN
+1,
44 /// Most restrictive alignment.
47 /// Size used by verbose mode.
48 /// 20 (date) + 15 (host_name) + 10 (pid) + 10 (type)
49 /// + 4 (@) ... + ? (progname)
52 /// Maximum size of a logging message with the verbose headers
53 MAXVERBOSELOGMSGLEN
= VERBOSE_LEN
+ MAXLOGMSGLEN
58 * Create a Log_Record and set its priority, time stamp, and
62 ACE_Log_Record (ACE_Log_Priority lp
,
65 ACE_Log_Record (ACE_Log_Priority lp
,
66 const ACE_Time_Value
&time_stamp
,
72 /// Write the contents of the logging record to the appropriate
73 /// FILE if the corresponding type is enabled.
74 int print (const ACE_TCHAR host_name
[],
76 #if !defined (ACE_LACKS_STDERR)
80 #endif /* ACE_LACKS_STDERR */
82 #if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
83 /// Write the contents of the logging record to the appropriate
84 /// @a stream if the corresponding type is enabled.
85 int print (const ACE_TCHAR host_name
[],
87 ACE_OSTREAM_TYPE
&stream
);
88 #endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */
90 int format_msg (const ACE_TCHAR host_name
[],
92 ACE_TCHAR
*verbose_msg
,
93 size_t verbose_msg_size
);
96 * Returns a character array with the string form of the
97 * ACE_Log_Priority parameter. This is used for the verbose
100 static const ACE_TCHAR
*priority_name (ACE_Log_Priority p
);
102 /// IMPORTANT: @a name must be a statically allocated const ACE_TCHAR*
103 static void priority_name (ACE_Log_Priority p
, const ACE_TCHAR
*name
);
105 /// Get the type of the Log_Record.
106 ACE_UINT32
type () const;
108 /// Set the type of the Log_Record.
109 void type (ACE_UINT32
);
111 /// Get the category of the Log_Record.
112 ACE_Log_Category_TSS
* category () const;
113 /// Set the category of the Log_Record.
114 void category (ACE_Log_Category_TSS
*);
117 * Get the priority of the Log_Record <type_>. This is computed
118 * as the base 2 logarithm of <type_> (which must be a power of 2,
119 * as defined by the enums in ACE_Log_Priority).
121 u_long
priority () const;
123 /// Set the priority of the Log_Record <type_> (which must be a
124 /// power of 2, as defined by the enums in ACE_Log_Priority).
125 void priority (u_long num
);
127 /// Get the total length of the Log_Record, which includes the
128 /// size of the various data member fields.
129 long length () const;
131 /// Set the total length of the Log_Record, which needs to account for
132 /// the size of the various data member fields.
135 /// Get the time stamp of the Log_Record.
136 ACE_Time_Value
time_stamp () const;
138 /// Set the time stamp of the Log_Record.
139 void time_stamp (const ACE_Time_Value
&ts
);
141 /// Get the process id of the Log_Record.
144 /// Set the process id of the Log_Record.
147 /// Get the message data of the Log_Record.
148 const ACE_TCHAR
*msg_data () const;
150 /// Set the message data of the record. If @a data is longer than the
151 /// current msg_data_ buffer, a new msg_data_ buffer is allocated to
152 /// fit. If such a reallocation fails, this method returns -1, else 0.
153 int msg_data (const ACE_TCHAR
*data
);
155 /// Get the size of the message data of the Log_Record, including
156 /// a byte for the NUL.
157 size_t msg_data_len () const;
159 /// Dump the state of an object.
162 /// Declare the dynamic allocation hooks.
163 ACE_ALLOC_HOOK_DECLARE
;
166 /// Round up to the alignment restrictions.
170 * Total length of the logging record in bytes. This field *must*
171 * come first in order for various IPC framing mechanisms to work
172 * correctly. In addition, the field must be an ACE_INT32 in order
173 * to be passed portable across platforms.
177 /// Type of logging record.
180 /// Time that the logging record was generated.
184 /// Id of process that generated the logging record.
187 /// Logging record data
188 ACE_TCHAR
*msg_data_
; // Heap-allocated text message area
190 /// Allocated size of msg_data_ in ACE_TCHARs
191 size_t msg_data_size_
;
194 ACE_Log_Category_TSS
* category_
;
196 ACE_Log_Record (const ACE_Log_Record
&) = delete;
197 ACE_Log_Record
& operator= (const ACE_Log_Record
&) = delete;
198 ACE_Log_Record (ACE_Log_Record
&&) = delete;
199 ACE_Log_Record
& operator= (ACE_Log_Record
&& rhs
) = delete;
206 // iostream operators for ACE_Log_Record.
207 ACE_Export
int operator>> (ACE_InputCDR
&cdr
, ACE_Log_Record
&log_record
);
208 ACE_Export
int operator<< (ACE_OutputCDR
&cdr
, const ACE_Log_Record
&log_record
);
210 ACE_END_VERSIONED_NAMESPACE_DECL
212 #if defined (__ACE_INLINE__)
213 #include "ace/Log_Record.inl"
214 #endif /* __ACE_INLINE__ */
216 #include /**/ "ace/post.h"
217 #endif /* ACE_LOG_RECORD_H */