activemq-cpp-3.9.5
StreamHandler.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17#ifndef _DECAF_UTIL_LOGGING_STREAMHANDLER_H_
18#define _DECAF_UTIL_LOGGING_STREAMHANDLER_H_
19
25#include <decaf/util/Config.h>
26
27namespace decaf{
28namespace io{
29 class OutputStream;
30 class Writer;
31}
32namespace util{
33namespace logging{
34
56 class DECAF_API StreamHandler : public Handler {
57 private:
58
59 // OutputStream to write to
61
62 // A Writer to wrap the OutputStream
63 decaf::io::Writer* writer;
64
65 // Indicates if the writer has been initialized already
66 bool writerNotInitialized;
67
68 private:
69
70 StreamHandler( const StreamHandler& );
71 StreamHandler& operator= ( const StreamHandler& );
72
73 public:
74
79
84
85 virtual ~StreamHandler();
86
97 virtual void close();
98
102 virtual void flush();
103
110 virtual void publish( const LogRecord& record );
111
120 virtual bool isLoggable( const LogRecord& record ) const;
121
122 protected:
123
137
145 void close( bool closeStream );
146
147 private:
148
149 // Safely writes the string to the output stream, calling the ErrorManager
150 // if any exceptions are thrown while writing.
151 void write( const std::string& value );
152
153 // Initialize the Writer if its not already been initialized.
154 void initializeWritter();
155
156 };
157
158}}}
159
160#endif /*_DECAF_UTIL_LOGGING_STREAMHANDLER_H_*/
Base interface for any class that wants to represent an output stream of bytes.
Definition OutputStream.h:39
Definition Writer.h:41
A Formatter provides support for formatting LogRecords.
Definition Formatter.h:37
LogRecord objects are used to pass logging requests between the logging framework and individual log ...
Definition LogRecord.h:41
virtual void publish(const LogRecord &record)
Publish the Log Record to this Handler.
virtual bool isLoggable(const LogRecord &record) const
Check if this Handler would actually log a given LogRecord.
StreamHandler(decaf::io::OutputStream *stream, Formatter *formatter)
Create a StreamHandler, with no current output stream.
virtual void setOuputStream(decaf::io::OutputStream *stream)
Change the output stream.
StreamHandler()
Create a StreamHandler, with no current output stream.
virtual void flush()
Flush the Handler's output, clears any buffers.
void close(bool closeStream)
Closes this handler, but the underlying output stream is only closed if closeStream is true.
virtual void close()
Close the current output stream.
#define DECAF_API
Definition Config.h:29
Definition BlockingByteArrayInputStream.h:25
Definition ConsoleHandler.h:28
Definition AbstractCollection.h:33
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25