2 ** Copyright 2001 Addison Wesley. All Rights Reserved.
5 #ifndef _LOGGING_HANDLER_H
6 #define _LOGGING_HANDLER_H
8 #include "ace/FILE_IO.h"
9 #include "ace/SOCK_Stream.h"
11 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
12 class ACE_Message_Block
;
13 ACE_END_VERSIONED_NAMESPACE_DECL
18 ACE_FILE_IO
*log_file_
; // Pointer to a log file.
20 ACE_SOCK_Stream logging_peer_
; // Connected to the client.
23 // Initialization and termination methods.
24 Logging_Handler (ACE_FILE_IO
&log_file
): log_file_ (&log_file
) {};
25 Logging_Handler (ACE_FILE_IO
&log_file
,
26 ACE_HANDLE handle
): log_file_ (&log_file
)
27 { logging_peer_
.set_handle (handle
); };
28 Logging_Handler (ACE_FILE_IO
&log_file
,
29 const ACE_SOCK_Stream
&logging_peer
)
30 : log_file_ (&log_file
), logging_peer_ (logging_peer
) {};
31 Logging_Handler (const ACE_SOCK_Stream
&logging_peer
)
32 : log_file_ (0), logging_peer_ (logging_peer
) {};
33 int close () { return logging_peer_
.close (); };
35 // Receive one log record from a connected client. Returns
36 // length of record on success and <mblk> contains the
37 // hostname, <mblk->cont()> contains the log record header
38 // (the byte order and the length) and the data. Returns -1 on
39 // failure or connection close.
40 int recv_log_record (ACE_Message_Block
*&log_record
);
42 // Write one record to the log file. The <mblk> contains the
43 // hostname and the <mblk->cont> contains the log record.
44 // Returns length of record written on success, or -1 on failure.
45 int write_log_record (ACE_Message_Block
*log_record
);
47 // Log one record by calling <recv_log_record> and
48 // <write_log_record>. Returns 0 on success and -1 on failure.
52 ACE_SOCK_Stream
&peer () { return logging_peer_
; };
55 #endif /* _LOGGING_HANDLER_H */