Use =default for skeleton copy constructor
[ACE_TAO.git] / ACE / examples / C++NPv2 / Logging_Event_Handler.cpp
blob5a4238b1e6c470949d22cd4d49b570d62935fe68
1 /*
2 ** Copyright 2002 Addison Wesley. All Rights Reserved.
3 */
5 #include "ace/FILE_Connector.h"
7 #include "Logging_Event_Handler.h"
8 #include "ace/OS_NS_string.h"
9 #include "ace/os_include/os_netdb.h"
11 int Logging_Event_Handler::open () {
12 static const char LOGFILE_SUFFIX[] = ".log";
13 char filename[MAXHOSTNAMELEN + sizeof (LOGFILE_SUFFIX)];
14 ACE_INET_Addr logging_peer_addr;
16 logging_handler_.peer ().get_remote_addr (logging_peer_addr);
17 logging_peer_addr.get_host_name (filename, MAXHOSTNAMELEN);
18 ACE_OS::strcat (filename, LOGFILE_SUFFIX);
20 ACE_FILE_Connector connector;
21 connector.connect (log_file_,
22 ACE_FILE_Addr (filename),
23 0, // No timeout.
24 ACE_Addr::sap_any, // Ignored.
25 0, // Don't try to reuse the addr.
26 O_RDWR|O_CREAT|O_APPEND,
27 ACE_DEFAULT_FILE_PERMS);
29 return reactor ()->register_handler
30 (this, ACE_Event_Handler::READ_MASK);
33 int Logging_Event_Handler::handle_input (ACE_HANDLE)
34 { return logging_handler_.log_record (); }
36 int Logging_Event_Handler::handle_close (ACE_HANDLE,
37 ACE_Reactor_Mask) {
38 logging_handler_.close ();
39 log_file_.close ();
40 delete this;
41 return 0;