log4cplus 2.0.8
win32consoleappender.h
Go to the documentation of this file.
1// -*- C++ -*-
2// Copyright (C) 2009-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#ifndef LOG4CPLUS_WIN32CONSOLEAPPENDER_H
26#define LOG4CPLUS_WIN32CONSOLEAPPENDER_H
27
28#include <log4cplus/config.hxx>
29
30#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
31#pragma once
32#endif
33
34#if defined(_WIN32) && defined (LOG4CPLUS_HAVE_WIN32_CONSOLE)
35
36#include <log4cplus/appender.h>
37
38
39namespace log4cplus
40{
41
64 : public Appender
65 {
66 public:
67 explicit Win32ConsoleAppender (bool allocConsole = true,
68 bool logToStdErr = false, unsigned int textColor = 0);
71
72 virtual void close ();
73
74 protected:
75 virtual void append (spi::InternalLoggingEvent const &);
76
77 void write_handle (void *, tchar const *, std::size_t);
78 void write_console (void *, tchar const *, std::size_t);
79
82 unsigned int text_color;
83
84 private:
86 Win32ConsoleAppender & operator = (Win32ConsoleAppender const &);
87 };
88
89} // namespace log4cplus
90
91#endif
92
93#endif // LOG4CPLUS_WIN32CONSOLEAPPENDER_H
Extend this class for implementing your own strategies for printing log statements.
Definition: appender.h:139
Prints events to Win32 console.
Win32ConsoleAppender(bool allocConsole=true, bool logToStdErr=false, unsigned int textColor=0)
void write_console(void *, tchar const *, std::size_t)
virtual void append(spi::InternalLoggingEvent const &)
Subclasses of Appender should implement this method to perform actual logging.
void write_handle(void *, tchar const *, std::size_t)
Win32ConsoleAppender(helpers::Properties const &properties)
virtual void close()
Release any resources allocated within the appender such as file handles, network connections,...
The internal representation of logging events.
Definition: loggingevent.h:51
char tchar
Definition: tchar.h:56
#define LOG4CPLUS_EXPORT
Definition: win32.h:141