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
}
Example #2
0
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 ());

#ifdef ACE_LACKS_VA_FUNCTIONS
#define LOG_ARGS
#else
#define LOG_ARGS(X) X
#endif
  log->log LOG_ARGS ((LM_ERROR, ACE_TEXT ("ACE_ASSERT: file %N, line %l assertion failed for '%s'.%a\n"), expression, -1));
}
Example #3
0
ACE_Trace::ACE_Trace (const ACE_TCHAR *n,
                      int line,
                      const ACE_TCHAR *file)
{
#if defined (ACE_NLOGGING)
  ACE_UNUSED_ARG (line);
  ACE_UNUSED_ARG (file);
#endif /* ACE_NLOGGING */

  this->name_ = n;

  // If ACE has not yet been initialized, don't try to trace... there's
  // too much stuff not yet initialized.
  if (ACE_Trace::enable_tracing_ && !ACE_OS_Object_Manager::starting_up ())
    {
      ACE_Log_Msg *lm = ACE_LOG_MSG;
      if (lm->tracing_enabled ()
          && lm->trace_active () == 0)
        {
          lm->trace_active (1);
          ACELIB_DEBUG ((LM_TRACE,
                      ACE_TEXT ("%*s(%t) calling %s in file `%s' on line %d\n"),
                      ACE_Trace::nesting_indent_ * lm->inc (),
                      ACE_TEXT (""),
                      this->name_,
                      file,
                      line));
          lm->trace_active (0);
        }
    }
}
Example #4
0
ACE_Trace::ACE_Trace (const ACE_TCHAR *n,
                      int line,
                      const ACE_TCHAR *file)
{
#if defined (ACE_NLOGGING)
  ACE_UNUSED_ARG (line);
  ACE_UNUSED_ARG (file);
#endif /* ACE_NLOGGING */

  this->name_ = n;

  if (ACE_Trace::enable_tracing_)
    {
      ACE_Log_Msg *lm = ACE_LOG_MSG;
      if (lm->tracing_enabled ()
          && lm->trace_active () == 0)
        {
          lm->trace_active (1);
          ACE_DEBUG ((LM_TRACE,
                      ACE_LIB_TEXT ("%*s(%t) calling %s in file `%s' on line %d\n"),
                      ACE_Trace::nesting_indent_ * lm->inc (),
                      ACE_LIB_TEXT (""),
                      this->name_,
                      file,
                      line));
          lm->trace_active (0);
        }
    }
}
Example #5
0
ACE_Trace::~ACE_Trace (void)
{
  if (ACE_Trace::enable_tracing_)
    {
      ACE_Log_Msg *lm = ACE_LOG_MSG;
      if (lm->tracing_enabled ()
          && lm->trace_active () == 0)
        {
          lm->trace_active (1);
          ACE_DEBUG ((LM_TRACE,
                      ACE_LIB_TEXT ("%*s(%t) leaving %s\n"),
                      ACE_Trace::nesting_indent_ * lm->dec (),
                      ACE_LIB_TEXT (""),
                      this->name_));
          lm->trace_active (0);
        }
    }
}
Example #6
0
ACE_Trace::~ACE_Trace (void)
{
  // If ACE has not yet been initialized, don't try to trace... there's
  // too much stuff not yet initialized.
  if (ACE_Trace::enable_tracing_ && !ACE_OS_Object_Manager::starting_up ())
    {
      ACE_Log_Msg *lm = ACE_LOG_MSG;
      if (lm->tracing_enabled ()
          && lm->trace_active () == 0)
        {
          lm->trace_active (1);
          ACELIB_DEBUG ((LM_TRACE,
                      ACE_TEXT ("%*s(%t) leaving %s\n"),
                      ACE_Trace::nesting_indent_ * lm->dec (),
                      ACE_TEXT (""),
                      this->name_));
          lm->trace_active (0);
        }
    }
}
  /**
   * Adds the log cathegory clear names corresponding to the cathegory
   * integer constants to the ACE_Log_Record.
   *
   * Parses the argument vector for the Miro command line option:
   * -MiroLogLevel, -MiroLogFilter and -MiroLogDevice.
   *
   * @TODO -MiroLogDevice has no effect. - Needs to be implemented.
   */
  void
  Log::init(int& argc, char * argv[]) 
  {
#if (GCC_MAJOR_VERSION >= 3)
    std::set_terminate (__gnu_cxx::__verbose_terminate_handler);
#endif

    mask_ = 0;
   // register all logging cathegories at the log record
    for (unsigned int i = 0; i < NUM_CATHEGORIES; ++i) {
      ACE_Log_Record::priority_name((ACE_Log_Priority)cathegories[i].priority, 
				    cathegories[i].name);
    }

    // parse command line arguments
    ACE_Arg_Shifter arg_shifter (argc, argv);
    while (arg_shifter.is_anything_left ()) {
      const ACE_TCHAR *currentArg = arg_shifter.get_current ();

      if (ACE_OS::strcasecmp(MIRO_LOG_LEVEL, currentArg) == 0 ||
	  ACE_OS::strcasecmp(MIRO_LOG_LEVEL_SHORT, currentArg) == 0 ) {
	arg_shifter.consume_arg();
	if (arg_shifter.is_parameter_next()) {
	  level_ = strtol(arg_shifter.get_current (), (char**)NULL, 10);
	  if (level_ == 0 && errno == ERANGE)
	    throw Miro::CException(errno, "Error parsing -MiroLogLevel");
	  arg_shifter.consume_arg();
	}
      }
      else if (ACE_OS::strcasecmp(MIRO_LOG_FILTER, currentArg) == 0 ||
	       ACE_OS::strcasecmp(MIRO_LOG_FILTER_SHORT, currentArg) == 0 ) {
	arg_shifter.consume_arg();

	while (arg_shifter.is_parameter_next()) {
	  unsigned int i;
	  for (i = 0; i < NUM_CATHEGORIES; ++i) {
	    if (ACE_OS::strcasecmp(cathegories[i].name, arg_shifter.get_current ()) == 0) {
	      unsigned long p;
	      ACE_Log_Msg *l = ACE_Log_Msg::instance ();
	      p = l->priority_mask(ACE_Log_Msg::PROCESS);
	      p |= cathegories[i].priority;
	      l->priority_mask(p, ACE_Log_Msg::PROCESS);

	      break;
	    }
	  }
	  if (i == NUM_CATHEGORIES)
	    throw Miro::Exception(std::string("Unknown parameter for -MiroLogFilter: ") + 
				  arg_shifter.get_current ());

	  arg_shifter.consume_arg();
	}
      }
      else if (ACE_OS::strcasecmp(MIRO_LOG_DEVICE, currentArg) == 0) {
	arg_shifter.consume_arg();

	if (arg_shifter.is_parameter_next()) {
	  logDevice = arg_shifter.get_current ();
	}
      }
      else {
	arg_shifter.ignore_arg ();
      }
    }

    mask_ = ACE_Log_Msg::instance()->priority_mask(ACE_Log_Msg::PROCESS);
  
//     for (unsigned int i = 0; i < 32; ++i) {
//       unsigned long p = 1UL << i;
//       if (mask_ & p) {
// 	std::cout << "logged cathegory: " 
// 		  << ACE_Log_Record::priority_name((ACE_Log_Priority) p) 
// 		  << std::endl;
//       }
//    }
  }
Example #8
0
//
// 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;
}