/usr/include/netsvcs/Log_Message_Receiver.h is in libnetsvcs-dev 6.0.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | /* -*- C++ -*- */
//=============================================================================
/**
* @file Log_Message_Receiver.h
*
* $Id: Log_Message_Receiver.h 91626 2010-09-07 10:59:20Z johnnyw $
*
* @author Per Andersson
*/
//=============================================================================
#ifndef LOG_MESSAGE_RECEIVER_H
#define LOG_MESSAGE_RECEIVER_H
#include "ace/Log_Record.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/Synch_Traits.h"
#include "ace/Guard_T.h"
#if defined (ACE_HAS_THREADS)
# include "ace/Thread_Mutex.h"
#else
# include "ace/Null_Mutex.h"
#endif /* ACE_HAS_THREADS */
// ==========================================================================//
//------------- General Requirements on a Log Message Receiver --------------//
// ==========================================================================//
//
// The requirements on a log manager receiver, T, are quite simple.
// 1: There must exist one "log_record" member function with the following
// prototype:
// void log_record(const ACE_TCHAR *hostname,
// ACE_Log_Record &record);
//
// 2: There must exist a public destructor.
// 3: There must exist a public copy constructor.
// 4: There must exist a default constructor. (for now)
//
// The semantics are also simple. A log message receiver should
// behave as an accessor object (smart pointer or envelope class).
// It should be very cheap to copy and the should be no noticeable
// difference when using either the new copy or the old log message
// receiver.
//
// Methods:
// void log_record(const ACE_TCHAR* hostname,
// ACE_Log_Record& record)
// Description:
// Processes the log record "record" from the host "hostname"
// Precondition:
// hostname != 0;
// Requirements:
// Record must be a valid ACE_Log_Record.
//
// ==========================================================================//
// ==========================================================================//
// ------------ General Description of a Log Message Receiver -------------- //
// ==========================================================================//
//
// Log Message Receivers, LRMs, are processing log records. It is the
// LRM that writes a log message to stderr, stdout, a log file and maybee
// converts some of the log messages to notifications, warnings, alarms
// and forwards them to some operation and maintenance system (PATROL).
//
// The client logging handler and server logging handler are responsible
// for forwarding, receiving, framing, processing log records.
// That is a very usable service, but it should also be possible to change
// how log records are processed without having to rewrite code in
// the server log handler. This code should instead be written as a
// separate entity, a Log Message Receiver.
//
// A simple LMR should be very easy to write but it should also
// be possible to write more complex LMRs, like one that creates
// a new log file each day or keeps a fixed size, round robin,
// log file. It should also be possible to have separate LMRs
// of the same type that uses differnt log files.
//
// ==========================================================================//
// Type based log message receiver
/**
* @class Static_Log_Message_Receiver
*
* @brief Static_Log_Message_Receiver is a simple log message receiver. It
* has no instance data and only static member
* functions. Static/typed based receivers are best when all LMR
* should do exactly the same thing.
*
* This class contains a static log_record member function that
* prints the content of log_records on stderr.
*/
template<ACE_SYNCH_DECL>
class Static_Log_Message_Receiver
{
public:
/// Prints the log_record to stderr using record.print (hostname, 0, stderr).
/// Serializes the output by using a ACE_SYNCH_MUTEX.
static void log_record(const ACE_TCHAR *hostname,
ACE_Log_Record &record);
/// Prints the log_record to a user specified ostream.
static void log_output(const ACE_TCHAR *hostname,
ACE_Log_Record &record,
ostream *output);
};
// Instance based log message receiver
// ------------------------ Log_Message_Receiver --------------------------- //
//
// Log_Message_Receiver is little more complicated log message receiver.
// It is instance based and have a reference counted implementation.
// Log_Message_Receiver is the envelope class for Log_Message_Receiver_Impl.
//
// ------------------------------------------------------------------------- //
//Forward declaration
template<ACE_SYNCH_DECL> class Log_Message_Receiver_Impl;
/**
* @class Log_Message_Receiver
*
* @brief Log_Message_Receiver is a little more complicated log message
* receiver. It is instance based and have a reference counted
* implementation. Log_Message_Receiver is the envelope class for
* Log_Message_Receiver_Impl. The difference between
* Static_Log_Message_Receiver and Log_Message_Receiver is that is
* possible to have instance data in Log_Message_Receiver.
* Comment:
* The practical usage of this is limited with the current
* ACE_Server_Logging_Acceptor_T design. Since
* ACE_Server_Logging_Acceptor_T will create the
* Log_Message_Receiver using the default constructor. The main
* reason for inclusion right now is to ensure that the code in
* ACE_Server_Logging_Handler_T works both with type and instance
* based LMRs.
*
* This class contains a log_record member function that prints the
* content of log_records on stderr.
*/
template<ACE_SYNCH_DECL>
class Log_Message_Receiver
{
public:
/// Creates a new Log_Message_Receiver
Log_Message_Receiver (void);
Log_Message_Receiver(Log_Message_Receiver<ACE_SYNCH_USE> const &rhs);
~Log_Message_Receiver (void);
void log_record (const ACE_TCHAR *hostname,
ACE_Log_Record &record);
void log_output(const ACE_TCHAR *hostname,
ACE_Log_Record &record,
ostream *output);
private:
ACE_UNIMPLEMENTED_FUNC (void operator= (const Log_Message_Receiver<ACE_SYNCH_USE> &rhs))
// Attributes.
Log_Message_Receiver_Impl<ACE_SYNCH_USE> *receiver_impl_;
};
/**
* @class Log_Message_Receiver_Impl
*
* @brief Implementation with reference count.
*/
template<ACE_SYNCH_DECL>
class Log_Message_Receiver_Impl : private ACE_Copy_Disabled
{
public:
// Methods for handling reference count and instance lifetime
static Log_Message_Receiver_Impl *create (void);
static Log_Message_Receiver_Impl *attach (Log_Message_Receiver_Impl<ACE_SYNCH_USE> *body);
static void detach (Log_Message_Receiver_Impl<ACE_SYNCH_USE> *body);
void log_record (const ACE_TCHAR *hostname, ACE_Log_Record &record);
void log_output(const ACE_TCHAR *hostname,
ACE_Log_Record &record,
ostream *output);
protected:
Log_Message_Receiver_Impl (void);
~Log_Message_Receiver_Impl (void);
/// Attributes
int count_;
ACE_SYNCH_MUTEX_T print_lock_;
private:
#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
static ACE_SYNCH_MUTEX_T copy_lock_;
#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
};
#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
#include "Log_Message_Receiver.cpp"
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
#pragma implementation ("Log_Message_Receiver.cpp")
#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
#endif /* LOG_MESSAGE_RECEIVER_H */
|