static int test_format_specs (void) { #if 0 Log_Spec_Verify verifier; ACE_Log_Msg logger; if (logger.open (ACE_TEXT ("Log_Msg_Test"), ACE_Log_Msg::MSG_CALLBACK) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("%T: test_format_specs open")), 1); logger.msg_callback (&verifier); logger.linenum (42); logger.file (ACE_TEXT ("Log_Msg_Test.cpp")); logger.log (LM_DEBUG, ACE_TEXT ("l1:%l")); logger.log (LM_DEBUG, ACE_TEXT ("l2:%5l")); logger.log (LM_DEBUG, ACE_TEXT ("l3N1:%0*l,%.7N"), 4); return verifier.result (); #else ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("l1:%l\n"))); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("l2:%5l\n"))); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("l3N1:%0*l,%.7N\n"), 4)); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%*ISTART INDENTING %{\n"), 4)); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%IONE%{\n"))); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%ITWO%{\n"))); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%ITHREE\n"))); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%}%ITWO\n"))); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%}%IONE\n"))); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%}%IENDINDENTING\n"))); errno = ENOENT; ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%m %p\n"), ACE_TEXT("perror"))); return 0; #endif }
ACE_BEGIN_VERSIONED_NAMESPACE_DECL // The following ASSERT macro is courtesy of Alexandre Karev // <*****@*****.**>. void __ace_assert(const char *file, int line, const ACE_TCHAR *expression) { int error = ACE_Log_Msg::last_error_adapter (); ACE_Log_Msg *log = ACE_Log_Msg::instance (); log->set (file, line, -1, error, log->restart (), log->msg_ostream (), log->msg_callback ()); log->log (LM_ERROR, ACE_TEXT ("ACE_ASSERT: file %N, line %l assertion failed for '%s'.%a\n"), expression, -1); }
// // init // int ACE_TMAIN (int argc, ACE_TCHAR * argv []) { try { OASIS::Standard_EINode einode; // Initialize the EINode. if (0 != einode.init (argc, argv)) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%T (%t) - %M - failed to initialize einode\n")), 1); // Load the configuration. if (0 != einode.load_configuration ("ace_logger.einode")) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%T (%t) - %M - failed to initialize einode\n")), 1); // Install the software probe. OASIS::ACE_Logging_Software_Probe ace_logger; ace_logger.init ("name="); einode.register_probe (&ace_logger); // Set the message callback for the logging framework. In this // case, its the software probe. ACE_Log_Msg * alm = ACE_Log_Msg::instance (); alm->set_flags (ACE_Log_Msg::MSG_CALLBACK); alm->clr_flags (ACE_Log_Msg::STDERR); alm->msg_callback (&ace_logger); // Activate the EINode if (0 != einode.activate ()) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%T (%t) - %M - failed to activate EINode\n")), 1); // Send messages via ACE_Log_Msg. ACE_LOG_MSG->log (LM_INFO, "This is message 1"); ACE_LOG_MSG->log (LM_INFO, "This is message 2"); ACE_LOG_MSG->log (LM_INFO, "This is message 3"); if (0 != einode.deactivate ()) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%T (%t) - %M - failed to deactivate EINode\n")), 1); // Finally, destroy the EINode. einode.destroy (); return 0; } catch (const std::exception & ex) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("%T (%t) - %M - %s\n"), ex.what ())); } return 1; }