activemq-cpp-3.8.2
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 
27 namespace decaf{
28 namespace io{
29  class OutputStream;
30  class Writer;
31 }
32 namespace util{
33 namespace 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 
78  StreamHandler();
79 
83  StreamHandler( decaf::io::OutputStream* stream, Formatter* formatter );
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 
136  virtual void setOuputStream( decaf::io::OutputStream* stream );
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_*/
Stream based logging Handler.
Definition: StreamHandler.h:56
LogRecord objects are used to pass logging requests between the logging framework and individual log ...
Definition: LogRecord.h:41
A Formatter provides support for formatting LogRecords.
Definition: Formatter.h:37
A Handler object takes log messages from a Logger and exports them.
Definition: Handler.h:49
Definition: Writer.h:41
#define DECAF_API
Definition: Config.h:29
Base interface for any class that wants to represent an output stream of bytes.
Definition: OutputStream.h:39
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25