blob: 355db9e5c56da35206811b7826e1e3ad4ba57914 (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
#include "tao/corba.h"
#include "ace/Log_Msg.h"
#include "ace/Log_Msg_Backend.h"
#include "ace/Log_Record.h"
const ACE_TCHAR* mykey = ACE_TEXT("KEY");
class Backend : public ACE_Log_Msg_Backend
{
public:
Backend ()
: ok_ (false) {}
virtual int open (const ACE_TCHAR *logger_key);
virtual int reset ();
virtual int close ();
virtual ssize_t log (ACE_Log_Record &log_record);
bool ok () const;
private:
bool ok_;
};
int
Backend::open (const ACE_TCHAR *key)
{
if (ACE_OS::strcmp (key, mykey) == 0)
this->ok_ = true;
return 0;
}
int
Backend::reset ()
{
return 0;
}
int
Backend::close ()
{
return 0;
}
ssize_t
Backend::log (ACE_Log_Record &)
{
return 1;
}
bool
Backend::ok () const
{
return this->ok_;
}
int ACE_TMAIN (int, ACE_TCHAR *argv[])
{
Backend b;
ACE_Log_Msg_Backend *old_b = ACE_Log_Msg::msg_backend (&b);
ACE_LOG_MSG->set_flags (ACE_Log_Msg::CUSTOM);
ACE_TCHAR *my_argv[3];
my_argv[0] = argv[0];
my_argv[1] = const_cast<ACE_TCHAR *> (ACE_TEXT ("-ORBServiceConfigLoggerKey"));
my_argv[2] = const_cast<ACE_TCHAR *> (mykey);
int my_argc = 3;
CORBA::ORB_var orb2_ = CORBA::ORB_init (my_argc, my_argv, "ServerORB1");
if (!b.ok ())
{
ACE_ERROR_RETURN ((LM_ERROR, "ERROR: Key not ok!\n"), 1);
}
// Reset the backend to avoid references to our soon-to-be-destroyed one.
ACE_Log_Msg::msg_backend (old_b);
return 0;
}
|