void KSGLogCallback::log(ACE_Log_Record& log_record) { ACE_TCHAR msg_data[ACE_Log_Record::MAXVERBOSELOGMSGLEN]; ACE_OS::sprintf(msg_data,"F[%s]L[%d]-%s\n",ACE_LOG_MSG->file() ,ACE_LOG_MSG->linenum(),log_record.msg_data()); log_record.msg_data(msg_data); }
void Logger::log (ACE_Log_Record &log_record) { int use_log_msg = 0; if (this->recursive_) { this->recursive_ = 0; use_log_msg = 1; } if (!this->verbose_logging_) { if (use_log_msg) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Logger::log->%s\n"), log_record.msg_data ())); #if !defined (ACE_LACKS_IOSTREAM_TOTALLY) else *ace_file_stream::instance ()->output_file () << "Recursive Logger callback = " << log_record.msg_data () << endl; #endif /* ACE_LACKS_IOSTREAM_TOTALLY */ } else { ACE_TCHAR verbose_msg[ACE_Log_Record::MAXVERBOSELOGMSGLEN]; int result = log_record.format_msg (ACE_LOG_MSG->local_host (), ACE_LOG_MSG->flags (), verbose_msg); if (result == 0) { if (use_log_msg) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Logger::log->%s\n"), verbose_msg)); #if !defined (ACE_LACKS_IOSTREAM_TOTALLY) else *ace_file_stream::instance ()->output_file () << "Recursive Logger callback = " << log_record.msg_data () << endl; #endif /* ACE_LACKS_IOSTREAM_TOTALLY */ } } // Cleanup on the way out. if (use_log_msg) this->recursive_ = 1; }
ssize_t NDDS_Log_Backend::log (ACE_Log_Record &log_record) { Log_Record *instance (0); instance = Log_RecordTypeSupport::create_data_ex (DDS_BOOLEAN_FALSE); if (instance == 0) { ACE_ERROR ((LM_EMERGENCY, ACE_TEXT ("Unable to create data sample for log record\n"))); return 0; } instance->node = this->node_.c_str (); instance->pid = log_record.pid (); instance->pid = log_record.pid (); instance->message = ACE_TEXT_ALWAYS_CHAR (log_record.msg_data ()); DDS_ReturnCode_t const retval = this->log_record_writer_->write (*instance, DDS_HANDLE_NIL); if (retval != DDS_RETCODE_OK) { ACE_ERROR ((LM_EMERGENCY, ACE_TEXT ("Unable to write log record to DDS\n"))); return 0; } if (instance != 0) { Log_RecordTypeSupport::delete_data_ex (instance, DDS_BOOLEAN_FALSE); } return log_record.msg_data_len (); }
ssize_t ACE_Log_Msg_Android_Logcat::log (ACE_Log_Record &log_record) { __android_log_write ( convert_log_priority (static_cast<ACE_Log_Priority> (log_record.type ())), "ACE", log_record.msg_data ()); return 0; }
void Logger::log (ACE_Log_Record &log_record) { int use_log_msg = 0; if (this->recursive_) { this->recursive_ = 0; use_log_msg = 1; } if (!this->verbose_logging_) { if (use_log_msg) ACE_DEBUG ((LM_DEBUG, "Logger::log->%s\n", log_record.msg_data ())); else ACE_OS::printf ("Recursive Logger callback = %s\n", log_record.msg_data ()); } else { ACE_TCHAR verbose_msg[ACE_Log_Record::MAXVERBOSELOGMSGLEN]; int result = log_record.format_msg (ACE_LOG_MSG->local_host (), ACE_LOG_MSG->flags (), verbose_msg); if (result == 0) { if (use_log_msg) ACE_DEBUG ((LM_DEBUG, "Logger::log->%s\n", verbose_msg)); else ACE_OS::printf ("Recursive Logger callback = %s\n", verbose_msg); } } // Cleanup on the way out. if (use_log_msg) this->recursive_ = 1; }
// // log // ssize_t CUTS_ACE_Msg_Backend::log (ACE_Log_Record &log_record) { this->logger_.log (log_record.priority (), log_record.msg_data (), log_record.length ()); // Manually invoke the old message callback if (this->old_msg_backend_ != 0) this->old_msg_backend_->log (log_record); return log_record.length (); }
int operator<< (ACE_OutputCDR &cdr, const ACE_Log_Record &log_record) { // The written message length can't be more than 32 bits (ACE_CDR::ULong) // so reduce it here if needed. ACE_CDR::ULong u_msglen = ACE_Utils::truncate_cast<ACE_CDR::ULong> (log_record.msg_data_len ()); // Insert each field from <log_record> into the output CDR stream. cdr << ACE_CDR::Long (log_record.type ()); cdr << ACE_CDR::Long (log_record.pid ()); cdr << ACE_CDR::LongLong (log_record.time_stamp ().sec ()); cdr << ACE_CDR::Long (log_record.time_stamp ().usec ()); cdr << u_msglen; #if defined (ACE_USES_WCHAR) cdr.write_wchar_array (log_record.msg_data (), u_msglen); #else cdr.write_char_array (log_record.msg_data (), u_msglen); #endif /* ACE_USES_WCHAR */ return cdr.good_bit (); }
void MFC_Log::log(ACE_Log_Record& log_record) { unsigned long priority = log_record.type(); char Message[512]; ACE_OS::sprintf(Message,"%d.%03ld %s", log_record.time_stamp().sec(), log_record.time_stamp().usec()/ 1000, log_record.msg_data()); #if defined (ACE_WIN32) ::OutputDebugString(Message); #endif /* ACE_WIN32 */ }
void Log_Spec_Verify::log (ACE_Log_Record &log_record) { const ACE_TCHAR *b = log_record.msg_data (); const ACE_TCHAR *expect = 0; if (ACE_OS::strncmp (b, ACE_TEXT ("l1:"), 3) == 0) { expect = ACE_TEXT ("42"); b += 4; //3 } else if (ACE_OS::strncmp (b, ACE_TEXT ("l2:"), 3) == 0) { expect = ACE_TEXT (" 42"); b += 3; } else if (ACE_OS::strncmp (b, ACE_TEXT ("l3N1:"), 4) == 0) { expect = ACE_TEXT ("0042,Log_Msg"); b += 4; } else { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Log_Spec_Verify, unrecognized test: %s\n"), b)); this->fail_++; } if (b != log_record.msg_data () && ACE_OS::strcmp (b, expect) != 0) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Test %s failed; expected %s\n"), log_record.msg_data (), expect)); this->fail_++; } return; }
int KSGLogBackend::log(ACE_Log_Record& log_record) { if(log_record.type() < _priority ) return 0; ACE_TCHAR msg_data[ACE_Log_Record::MAXVERBOSELOGMSGLEN]; ACE_OS::sprintf(msg_data,"P[%d]F[%s]L[%d]- %s\n",ACE_OS::thr_self(),ACE_LOG_MSG->file() ,ACE_LOG_MSG->linenum(),log_record.msg_data()); log_record.msg_data(msg_data); log_record.format_msg(ACE_LOG_MSG->local_host(),ACE_LOG_MSG->flags() ,msg_data); int len = ACE_OS::strlen(msg_data); if(_log_app & laStdout) ACE_OS::printf(msg_data); if(_log_app & laFile) log2file(msg_data,len); #ifndef WIN32 if(_log_app & laSyslog) log2syslog(log_record); #endif return 0; }
ssize_t ACE_Log_Msg_UNIX_Syslog::log (ACE_Log_Record &log_record) { int syslog_priority = this->convert_log_priority (log_record.type ()); u_long flags = ACE_LOG_MSG->flags (); // The UNIX syslog() facility does not support multi-line messages. // Break up the message data into separate lines and send each line // to the syslog daemon. ACE_TCHAR message[ACE_Log_Record::MAXVERBOSELOGMSGLEN]; ACE_OS::strcpy (message, log_record.msg_data ()); ACE_TCHAR *strtokp = 0; for (ACE_TCHAR *line = ACE_OS::strtok_r (message, ACE_TEXT ("\n"), &strtokp); line != 0; line = ACE_OS::strtok_r (0, ACE_TEXT ("\n"), &strtokp)) { // Format the message line. Note that the processing for // VERBOSE is the same as for VERBOSE_LITE, since syslog() // already provides us with the hostname and PID. However, the // timestamp is duplicated (albeit a shortened version) to // provide a timestamp with greater precision than that provided // by syslog(). if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::VERBOSE) || ACE_BIT_ENABLED (flags, ACE_Log_Msg::VERBOSE_LITE)) { ACE_TCHAR date_and_time[35]; if (0 == ACE::timestamp (date_and_time, sizeof (date_and_time), 1)) ACE_OS::strcpy (date_and_time, ACE_TEXT ("<time error>")); const ACE_TCHAR *prio_name = ACE_Log_Record::priority_name(ACE_Log_Priority(log_record.type())); syslog (syslog_priority, "%s: %s: %s", ACE_TEXT_ALWAYS_CHAR (date_and_time), ACE_TEXT_ALWAYS_CHAR (prio_name), ACE_TEXT_ALWAYS_CHAR (line)); } else // No formatting required. syslog (syslog_priority, "%s", ACE_TEXT_ALWAYS_CHAR (line)); } return 0; }
ssize_t ACE_Log_Msg_NT_Event_Log::log (ACE_Log_Record &log_record) { // Make a copy of the log text and replace any newlines with // CR-LF. Newline characters on their own do not appear correctly in // the event viewer. We allow for a doubling in the size of the msg // data for the worst case of all newlines. const ACE_TCHAR *src_msg_data = log_record.msg_data (); ACE_TCHAR msg_data [(ACE_Log_Record::MAXLOGMSGLEN * 2) + 1]; size_t maxlen = ACE_Log_Record::MAXLOGMSGLEN; if (ACE_Log_Record::MAXLOGMSGLEN > log_record.msg_data_len ()) maxlen = log_record.msg_data_len (); size_t end = 0; for (size_t i = 0, j = 0; i < maxlen; ++i) { if (src_msg_data[i] == '\n') { msg_data[j++] = '\r'; msg_data[j++] = '\n'; } else msg_data[j++] = src_msg_data[i]; end = j; } msg_data[end] = '\0'; // Map the ACE log record type to an event log type. WORD event_type; switch (log_record.type ()) { case LM_STARTUP: case LM_SHUTDOWN: case LM_TRACE: case LM_DEBUG: case LM_INFO: event_type = EVENTLOG_INFORMATION_TYPE; break; case LM_NOTICE: case LM_WARNING: event_type = EVENTLOG_WARNING_TYPE; break; case LM_ERROR: case LM_CRITICAL: case LM_ALERT: case LM_EMERGENCY: default: event_type = EVENTLOG_ERROR_TYPE; break; } // Send the log message to the system event log. const ACE_TCHAR* msgs [1]; msgs[0] = msg_data; if (ACE_TEXT_ReportEvent (this->evlog_handle_, event_type, 0, 0, 0, 1, 0, msgs, 0) == 0) return -1; else return 0; }
void Log_Spec_Verify::log (ACE_Log_Record &log_record) { bool use_log_msg = false; if (this->recursive_) { this->recursive_ = false; use_log_msg = true; } if (!use_log_msg) { #if !defined (ACE_LACKS_IOSTREAM_TOTALLY) *ace_file_stream::instance ()->output_file () << "Logger callback = " << log_record.msg_data () << endl; #endif /* ACE_LACKS_IOSTREAM_TOTALLY */ } else { const ACE_TCHAR *b = log_record.msg_data (); const ACE_TCHAR *expect = 0; ++this->tests_; if (ACE_OS::strncmp (b, ACE_TEXT ("l1:"), 3) == 0) { expect = ACE_TEXT ("42"); b += 3; } else if (ACE_OS::strncmp (b, ACE_TEXT ("l2:"), 3) == 0) { expect = ACE_TEXT (" 42"); b += 3; } else if (ACE_OS::strncmp (b, ACE_TEXT ("l3N1:"), 4) == 0) { expect = ACE_TEXT ("0042,Log_Msg"); b += 5; } else if (ACE_OS::strncmp (b, ACE_TEXT ("l4:"), 3) == 0) { b += 3; // Check if we have a string, exact length could vary if (b != log_record.msg_data () && ACE_OS::strlen (b) < 15) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Test %s failed; expected %d\n"), log_record.msg_data (), ACE_OS::strlen (b))); ++this->fail_; } } else if (ACE_OS::strncmp (b, ACE_TEXT ("l5:"), 3) == 0) { b += 3; switch (log_record.type()) { case (LM_SHUTDOWN): expect = ACE_TEXT("S"); break; case (LM_TRACE): expect = ACE_TEXT("T"); break; case (LM_DEBUG): expect = ACE_TEXT("D"); break; case (LM_INFO): expect = ACE_TEXT("I"); break; case (LM_NOTICE): expect = ACE_TEXT("N"); break; case (LM_WARNING): expect = ACE_TEXT("W"); break; case (LM_STARTUP): expect = ACE_TEXT("U"); break; case (LM_ERROR): expect = ACE_TEXT("E"); break; case (LM_CRITICAL): expect = ACE_TEXT("C"); break; case (LM_ALERT): expect = ACE_TEXT("A"); break; case (LM_EMERGENCY): expect = ACE_TEXT("!"); break; default: expect = ACE_TEXT("?"); break; } } else { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Log_Spec_Verify, unrecognized test: %s\n"), b)); ++this->fail_; } if (b != log_record.msg_data () && expect && ACE_OS::strcmp (b, expect) != 0) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Test %s failed; expected %s\n"), log_record.msg_data (), expect)); ++this->fail_; } } // Cleanup on the way out. if (use_log_msg) this->recursive_ = true; }
void Log_Spec_Verify::log (ACE_Log_Record &log_record) { bool use_log_msg = false; if (this->recursive_) { this->recursive_ = false; use_log_msg = true; } if (!use_log_msg) { #if !defined (ACE_LACKS_IOSTREAM_TOTALLY) *ace_file_stream::instance ()->output_file () << "Logger callback = " << log_record.msg_data () << endl; #endif /* ACE_LACKS_IOSTREAM_TOTALLY */ } else { const ACE_TCHAR *b = log_record.msg_data (); const ACE_TCHAR *expect = 0; ++this->tests_; if (ACE_OS::strncmp (b, ACE_TEXT ("l1:"), 3) == 0) { expect = ACE_TEXT ("42"); b += 3; } else if (ACE_OS::strncmp (b, ACE_TEXT ("l2:"), 3) == 0) { expect = ACE_TEXT (" 42"); b += 3; } else if (ACE_OS::strncmp (b, ACE_TEXT ("l3N1:"), 4) == 0) { expect = ACE_TEXT ("0042,Log_Msg"); b += 5; } else if (ACE_OS::strncmp (b, ACE_TEXT ("l4:"), 3) == 0) { b += 3; // Check if we have a string, exact length could vary if (b != log_record.msg_data () && ACE_OS::strlen (b) < 15) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Test %s failed; expected %d\n"), log_record.msg_data (), ACE_OS::strlen (b))); ++this->fail_; } } else { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Log_Spec_Verify, unrecognized test: %s\n"), b)); ++this->fail_; } if (b != log_record.msg_data () && expect && ACE_OS::strcmp (b, expect) != 0) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Test %s failed; expected %s\n"), log_record.msg_data (), expect)); ++this->fail_; } } // Cleanup on the way out. if (use_log_msg) this->recursive_ = true; }