OFFIS DCMTK
Version 3.6.0
Main Page
Related Pages
Classes
Files
File List
File Members
oflog
include
dcmtk
oflog
socketap.h
Go to the documentation of this file.
1
// Module: LOG4CPLUS
2
// File: socketappender.h
3
// Created: 5/2003
4
// Author: Tad E. Smith
5
//
6
//
7
// Copyright 2003-2009 Tad E. Smith
8
//
9
// Licensed under the Apache License, Version 2.0 (the "License");
10
// you may not use this file except in compliance with the License.
11
// You may obtain a copy of the License at
12
//
13
// http://www.apache.org/licenses/LICENSE-2.0
14
//
15
// Unless required by applicable law or agreed to in writing, software
16
// distributed under the License is distributed on an "AS IS" BASIS,
17
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
// See the License for the specific language governing permissions and
19
// limitations under the License.
20
23
#ifndef _LOG4CPLUS_SOCKET_APPENDER_HEADER_
24
#define _LOG4CPLUS_SOCKET_APPENDER_HEADER_
25
26
#include "dcmtk/oflog/config.h"
27
#include "
dcmtk/oflog/appender.h
"
28
#include "
dcmtk/oflog/helpers/socket.h
"
29
#include "dcmtk/oflog/helpers/syncprims.h"
30
31
32
#define LOG4CPLUS_MAX_MESSAGE_SIZE (8*1024)
33
34
35
namespace
log4cplus {
36
88
class
LOG4CPLUS_EXPORT
SocketAppender
:
public
Appender
{
89
public
:
90
// Ctors
91
SocketAppender
(
const
log4cplus::tstring
& host,
int
port,
92
const
log4cplus::tstring
& serverName =
tstring
());
93
SocketAppender
(
const
log4cplus::helpers::Properties
& properties,
log4cplus::tstring
& error);
94
95
// Dtor
96
~
SocketAppender
();
97
98
// Methods
99
virtual
void
close();
100
101
protected
:
102
void
openSocket();
103
void
initConnector ();
104
virtual
void
append(
const
spi::InternalLoggingEvent
& event);
105
106
// Data
107
log4cplus::helpers::Socket
socket;
108
log4cplus::tstring
host;
109
int
port;
110
log4cplus::tstring
serverName;
111
112
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
113
class
LOG4CPLUS_EXPORT ConnectorThread;
114
friend
class
ConnectorThread;
115
116
class
LOG4CPLUS_EXPORT ConnectorThread
117
:
public
thread::AbstractThread
118
,
public
helpers::LogLogUser
119
{
120
public
:
121
ConnectorThread (
SocketAppender
&);
122
virtual
~ConnectorThread ();
123
124
virtual
void
run();
125
126
void
terminate ();
127
void
trigger ();
128
129
protected
:
130
SocketAppender
& sa;
131
thread::ManualResetEvent
trigger_ev;
132
bool
exit_flag;
133
};
134
135
volatile
bool
connected;
136
helpers::SharedObjectPtr<ConnectorThread>
connector;
137
#endif
138
139
private
:
140
// Disallow copying of instances of this class
141
SocketAppender
(
const
SocketAppender
&);
142
SocketAppender
& operator=(
const
SocketAppender
&);
143
};
144
145
namespace
helpers {
146
LOG4CPLUS_EXPORT
147
SocketBuffer convertToBuffer(
const
log4cplus::spi::InternalLoggingEvent
& event,
148
const
log4cplus::tstring
& serverName);
149
150
LOG4CPLUS_EXPORT
151
log4cplus::spi::InternalLoggingEvent
readFromBuffer(SocketBuffer& buffer);
152
}
// end namespace helpers
153
154
}
// end namespace log4cplus
155
156
#endif // _LOG4CPLUS_SOCKET_APPENDER_HEADER_
157
Generated on Thu Dec 20 2012 for
OFFIS DCMTK
Version 3.6.0 by
Doxygen
1.8.2