summaryrefslogtreecommitdiff
path: root/netsvcs/clients/Logger/indirect_logging.cpp
blob: 6a0698e1c90047eeafc0d3f7e6a40507275c3cb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// $Id$

// This is a simple test that sends logging records to the Client
// Logging Daemon running on the localhost.  This daemon then forwards
// them to the Server Logging Daemon.  If there is no Server Logging
// Daemon, the logging records will be written to stderr.

#include "ace/OS.h"

int 
main (int argc, char *argv[])
{
  const char *prog_name  = argv[0];
  int iterations  = argc < 2 ? 10 : ACE_OS::atoi (argv[1]);
  const char *logger_key = argc < 3 ? ACE_DEFAULT_LOGGER_KEY : argv[2];

  ACE_OS::srand ((u_int) ACE_OS::time (0));

  ACE_LOG_MSG->open (prog_name, ACE_Log_Msg::LOGGER,
		     ACE_WIDE_STRING (logger_key));

  ACE_DEBUG ((LM_STARTUP, "starting up the test\n"));

  for (int i = 0; i < iterations; i++)
    {
      size_t priority = ACE_OS::rand () % int (LM_MAX);
      ACE_POW (priority);
      ACE_DEBUG ((ACE_Log_Priority (priority), 
		  "random message %d...\n", 
		  priority));
    }

  ACE_DEBUG ((LM_SHUTDOWN, "closing down the test\n"));
  return 0;
}