Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tests / Bug_3597_Regression / server.cpp
blob355db9e5c56da35206811b7826e1e3ad4ba57914
1 #include "tao/corba.h"
2 #include "ace/Log_Msg.h"
3 #include "ace/Log_Msg_Backend.h"
4 #include "ace/Log_Record.h"
6 const ACE_TCHAR* mykey = ACE_TEXT("KEY");
8 class Backend : public ACE_Log_Msg_Backend
10 public:
11 Backend ()
12 : ok_ (false) {}
14 virtual int open (const ACE_TCHAR *logger_key);
16 virtual int reset ();
18 virtual int close ();
20 virtual ssize_t log (ACE_Log_Record &log_record);
22 bool ok () const;
24 private:
25 bool ok_;
28 int
29 Backend::open (const ACE_TCHAR *key)
31 if (ACE_OS::strcmp (key, mykey) == 0)
32 this->ok_ = true;
33 return 0;
36 int
37 Backend::reset ()
39 return 0;
42 int
43 Backend::close ()
45 return 0;
48 ssize_t
49 Backend::log (ACE_Log_Record &)
51 return 1;
54 bool
55 Backend::ok () const
57 return this->ok_;
60 int ACE_TMAIN (int, ACE_TCHAR *argv[])
62 Backend b;
63 ACE_Log_Msg_Backend *old_b = ACE_Log_Msg::msg_backend (&b);
65 ACE_LOG_MSG->set_flags (ACE_Log_Msg::CUSTOM);
67 ACE_TCHAR *my_argv[3];
68 my_argv[0] = argv[0];
69 my_argv[1] = const_cast<ACE_TCHAR *> (ACE_TEXT ("-ORBServiceConfigLoggerKey"));
70 my_argv[2] = const_cast<ACE_TCHAR *> (mykey);
71 int my_argc = 3;
73 CORBA::ORB_var orb2_ = CORBA::ORB_init (my_argc, my_argv, "ServerORB1");
75 if (!b.ok ())
77 ACE_ERROR_RETURN ((LM_ERROR, "ERROR: Key not ok!\n"), 1);
80 // Reset the backend to avoid references to our soon-to-be-destroyed one.
81 ACE_Log_Msg::msg_backend (old_b);
83 return 0;