本文整理汇总了C++中ACE_Log_Msg::msg_callback方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Log_Msg::msg_callback方法的具体用法?C++ ACE_Log_Msg::msg_callback怎么用?C++ ACE_Log_Msg::msg_callback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_Log_Msg
的用法示例。
在下文中一共展示了ACE_Log_Msg::msg_callback方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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
}
示例2:
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// The following ASSERT macro is courtesy of Alexandre Karev
// <[email protected]>.
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);
}
示例3: ACE_TMAIN
//
// 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;
}