Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / examples / APG / Logging / Callback-2.h
blob47270a013f86b81c951eb201ab4e5b66258d43f1
1 #ifndef APG_CALLBACK2_H
2 #define APG_CALLBACK2_H
4 #include "ace/OS_NS_time.h"
5 #include "ace/streams.h"
6 #include "ace/Log_Msg_Callback.h"
7 #include "ace/Log_Record.h"
8 #include "ace/SString.h"
9 #include "ace/Time_Value.h"
11 class Callback : public ACE_Log_Msg_Callback
13 public:
14 void log (ACE_Log_Record &log_record)
16 cerr << "Log Message Received:" << endl;
17 unsigned long msg_severity = log_record.type ();
18 ACE_Log_Priority prio =
19 static_cast<ACE_Log_Priority> (msg_severity);
20 const ACE_TCHAR *prio_name =
21 ACE_Log_Record::priority_name (prio);
22 cerr << "\tType: "
23 << ACE_TEXT_ALWAYS_CHAR (prio_name)
24 << endl;
26 cerr << "\tLength: " << log_record.length () << endl;
28 const time_t epoch = log_record.time_stamp ().sec ();
29 cerr << "\tTime_Stamp: "
30 << ACE_TEXT_ALWAYS_CHAR (ACE_OS::ctime (&epoch))
31 << flush;
33 cerr << "\tPid: " << log_record.pid () << endl;
35 ACE_CString data (">> ");
36 data += ACE_TEXT_ALWAYS_CHAR (log_record.msg_data ());
38 cerr << "\tMsgData: " << data.c_str () << endl;
42 #endif /* APG_CALLBACK2_H */