Apache Qpid C++ API
Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET Apache Qpid Documentation

qpid/log/Logger.h

Go to the documentation of this file.
00001 #ifndef QPID_LOG_LOGGER_H
00002 #define QPID_LOG_LOGGER_H
00003 
00004 /*
00005  *    http://www.apache.org/licenses/LICENSE-2.0
00006  *
00007  * Unless required by applicable law or agreed to in writing, software
00008  * distributed under the License is distributed on an "AS IS" BASIS,
00009  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00010  * See the License for the specific language governing permissions and
00011  * limitations under the License.
00012  *
00013  */
00014 
00015 #include "qpid/log/Selector.h"
00016 #include "qpid/log/Options.h"
00017 #include "qpid/sys/Mutex.h"
00018 #include <boost/ptr_container/ptr_vector.hpp>
00019 #include <boost/noncopyable.hpp>
00020 #include <set>
00021 #include "qpid/CommonImportExport.h"
00022 
00023 namespace qpid {
00024 namespace log {
00025 
00036 class Logger : private boost::noncopyable {
00037   public:
00039     enum FormatFlag { FILE=1, LINE=2, FUNCTION=4, LEVEL=8, TIME=16, THREAD=32};
00040 
00050     class Output {
00051       public:
00052         QPID_COMMON_EXTERN Output();
00053         QPID_COMMON_EXTERN virtual ~Output();
00055         virtual void log(const Statement&, const std::string&) =0;
00056     };
00057 
00058     QPID_COMMON_EXTERN static Logger& instance();
00059 
00060     QPID_COMMON_EXTERN Logger();
00061     QPID_COMMON_EXTERN ~Logger();
00062 
00064     QPID_COMMON_EXTERN void select(const Selector& s);
00065 
00067     QPID_COMMON_EXTERN void format(int formatFlags);
00068 
00072     QPID_COMMON_EXTERN int format(const Options&);
00073 
00075     QPID_COMMON_EXTERN void configure(const Options& o);
00076 
00078     QPID_COMMON_EXTERN void add(Statement& s);
00079 
00081     QPID_COMMON_EXTERN void log(const Statement&, const std::string&);
00082 
00084     QPID_COMMON_EXTERN void output(std::auto_ptr<Output> out);
00085 
00087     QPID_COMMON_EXTERN void setPrefix(const std::string& prefix);
00088 
00090     QPID_COMMON_EXTERN void clear();
00091 
00093     QPID_COMMON_EXTERN const Options& getOptions() const { return options; }
00094 
00095 
00096   private:
00097     typedef boost::ptr_vector<Output> Outputs;
00098     typedef std::set<Statement*> Statements;
00099 
00100     sys::Mutex lock;
00101     inline void enable_unlocked(Statement* s);
00102 
00103     Statements statements;
00104     Outputs outputs;
00105     Selector selector;
00106     int flags;
00107     std::string prefix;
00108     Options options;
00109 };
00110 
00111 }} // namespace qpid::log
00112 
00113 
00114 #endif  

Qpid C++ API Reference
Generated on Wed Dec 1 10:01:43 2010 for Qpid C++ Client API by doxygen 1.4.7