log4cplus  2.0.0
callbackappender.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //  Copyright (C) 2015, Vaclav Haisman. All rights reserved.
00003 //
00004 //  Redistribution and use in source and binary forms, with or without modifica-
00005 //  tion, are permitted provided that the following conditions are met:
00006 //
00007 //  1. Redistributions of  source code must  retain the above copyright  notice,
00008 //     this list of conditions and the following disclaimer.
00009 //
00010 //  2. Redistributions in binary form must reproduce the above copyright notice,
00011 //     this list of conditions and the following disclaimer in the documentation
00012 //     and/or other materials provided with the distribution.
00013 //
00014 //  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
00015 //  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
00016 //  FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
00017 //  APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
00018 //  INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
00019 //  DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
00020 //  OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
00021 //  ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
00022 //  (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
00023 //  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00024 
00025 
00028 #ifndef LOG4CPLUS_CALLBACK_APPENDER_HEADER_
00029 #define LOG4CPLUS_CALLBACK_APPENDER_HEADER_
00030 
00031 #include <log4cplus/config.hxx>
00032 
00033 #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
00034 #pragma once
00035 #endif
00036 
00037 #include <log4cplus/appender.h>
00038 #include <log4cplus/clogger.h>
00039 
00040 
00041 namespace log4cplus {
00042 
00046 class LOG4CPLUS_EXPORT CallbackAppender
00047     : public Appender {
00048 public:
00049     CallbackAppender();
00050     CallbackAppender(log4cplus_log_event_callback_t callback, void * cookie);
00051     CallbackAppender(const log4cplus::helpers::Properties&);
00052 
00053     virtual ~CallbackAppender();
00054     virtual void close();
00055 
00056     void setCookie(void *);
00057     void setCallback(log4cplus_log_event_callback_t);
00058 
00059 protected:
00060     virtual void append(const log4cplus::spi::InternalLoggingEvent& event);
00061 
00062 private:
00063     log4cplus_log_event_callback_t callback;
00064     void * cookie;
00065 
00066     // Disallow copying of instances of this class
00067     CallbackAppender(const CallbackAppender&) = delete;
00068     CallbackAppender& operator=(const CallbackAppender&) = delete;
00069 };
00070 
00071 } // end namespace log4cplus
00072 
00073 #endif // LOG4CPLUS_CALLBACK_APPENDER_HEADER_