log4cplus  2.1.0
callbackappender.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 // Copyright (C) 2015-2017, Vaclav Haisman. All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without modifica-
5 // tion, are permitted provided that the following conditions are met:
6 //
7 // 1. Redistributions of source code must retain the above copyright notice,
8 // this list of conditions and the following disclaimer.
9 //
10 // 2. Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 //
14 // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
15 // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
17 // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
19 // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
20 // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 
25 
28 #ifndef LOG4CPLUS_CALLBACK_APPENDER_HEADER_
29 #define LOG4CPLUS_CALLBACK_APPENDER_HEADER_
30 
31 #include <log4cplus/config.hxx>
32 
33 #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
34 #pragma once
35 #endif
36 
37 #include <log4cplus/appender.h>
38 #include <log4cplus/clogger.h>
39 
40 
41 namespace log4cplus {
42 
47  : public Appender {
48 public:
52 
53  virtual ~CallbackAppender();
54  virtual void close();
55 
56  void setCookie(void *);
58 
59 protected:
60  virtual void append(const log4cplus::spi::InternalLoggingEvent& event);
61 
62 private:
64  void * cookie;
65 
66  // Disallow copying of instances of this class
67  CallbackAppender(const CallbackAppender&) = delete;
68  CallbackAppender& operator=(const CallbackAppender&) = delete;
69 };
70 
71 } // end namespace log4cplus
72 
73 #endif // LOG4CPLUS_CALLBACK_APPENDER_HEADER_
Extend this class for implementing your own strategies for printing log statements.
Definition: appender.h:139
Send log events to a C function callback.
void setCallback(log4cplus_log_event_callback_t)
virtual void append(const log4cplus::spi::InternalLoggingEvent &event)
Subclasses of Appender should implement this method to perform actual logging.
CallbackAppender(log4cplus_log_event_callback_t callback, void *cookie)
virtual void close()
Release any resources allocated within the appender such as file handles, network connections,...
CallbackAppender(const log4cplus::helpers::Properties &)
The internal representation of logging events.
Definition: loggingevent.h:51
Module: Log4CPLUS File: clogger.h Created: 01/2011 Author: Jens Rehsack.
void(* log4cplus_log_event_callback_t)(void *cookie, log4cplus_char_t const *message, log4cplus_char_t const *loggerName, log4cplus_loglevel_t ll, log4cplus_char_t const *thread, log4cplus_char_t const *thread2, unsigned long long timestamp_secs, unsigned long timestamp_usecs, log4cplus_char_t const *file, log4cplus_char_t const *function, int line)
CallbackAppender callback type.
Definition: clogger.h:105
#define LOG4CPLUS_EXPORT
Definition: win32.h:141