File: Logging_Handler.h

package info (click to toggle)
ace 6.2.8%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 49,348 kB
  • ctags: 42,082
  • sloc: cpp: 342,284; perl: 32,718; ansic: 20,838; sh: 3,759; python: 828; exp: 787; yacc: 511; xml: 330; lex: 158; lisp: 116; makefile: 82; csh: 20; tcl: 5
file content (57 lines) | stat: -rw-r--r-- 1,911 bytes parent folder | download
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
/*
** $Id: Logging_Handler.h 80826 2008-03-04 14:51:23Z wotte $
**
** Copyright 2001 Addison Wesley. All Rights Reserved.
*/

#ifndef _LOGGING_HANDLER_H
#define _LOGGING_HANDLER_H

#include "ace/FILE_IO.h"
#include "ace/SOCK_Stream.h"

ACE_BEGIN_VERSIONED_NAMESPACE_DECL
class ACE_Message_Block;
ACE_END_VERSIONED_NAMESPACE_DECL

class Logging_Handler
{
protected:
  ACE_FILE_IO *log_file_; // Pointer to a log file.

  ACE_SOCK_Stream logging_peer_; // Connected to the client.

public:
  // Initialization and termination methods.
  Logging_Handler (ACE_FILE_IO &log_file): log_file_ (&log_file) {};
  Logging_Handler (ACE_FILE_IO &log_file,
                   ACE_HANDLE handle): log_file_ (&log_file)
    { logging_peer_.set_handle (handle); };
  Logging_Handler (ACE_FILE_IO &log_file,
                   const ACE_SOCK_Stream &logging_peer)
    : log_file_ (&log_file), logging_peer_ (logging_peer) {};
  Logging_Handler (const ACE_SOCK_Stream &logging_peer)
    : log_file_ (0), logging_peer_ (logging_peer) {};
  int close () { return logging_peer_.close (); };

  // Receive one log record from a connected client.   Returns
  // length of record on success and <mblk> contains the
  // hostname, <mblk->cont()> contains the log record header
  // (the byte order and the length) and the data.  Returns -1 on
  // failure or connection close.
  int recv_log_record (ACE_Message_Block *&log_record);

  // Write one record to the log file.  The <mblk> contains the
  // hostname and the <mblk->cont> contains the log record.
  // Returns length of record written on success, or -1 on failure.
  int write_log_record (ACE_Message_Block *log_record);

  // Log one record by calling <recv_log_record> and
  // <write_log_record>.  Returns 0 on success and -1 on failure.
  int log_record ();

  // Accessor method.
  ACE_SOCK_Stream &peer () { return logging_peer_; };
};

#endif /* _LOGGING_HANDLER_H */