Skip to content

Commit

Permalink
link against libsocket on qnx, add synchronous ostream appender
Browse files Browse the repository at this point in the history
  • Loading branch information
cmsd2 committed Feb 21, 2013
1 parent ecb2bf2 commit ff5d3b2
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Jamroot
@@ -1,7 +1,7 @@
project log4cpp ;

alias sockets : : <toolset>gcc ;
alias sockets : : <toolset>qcc ;
lib sockets : : <name>socket <toolset>qcc ;
lib sockets : : <name>ws2_32 <toolset>gcc <os>NT ;
lib sockets : : <name>ws2_32 <toolset>msvc ;
lib sockets : : <name>ws2_32.lib <toolset>borland ;
Expand Down
3 changes: 3 additions & 0 deletions common.mk
Expand Up @@ -19,6 +19,9 @@ LDFLAGS+=-lang-c++

VFLAG_g=-gstabs+

#===== LIBS - a space-separated list of library items to be included in the link.
LIBS+=socket

include $(MKFILES_ROOT)/qmacros.mk
ifndef QNX_INTERNAL
QNX_INTERNAL=$(PROJECT_ROOT)/.qnx_internal.mk
Expand Down
34 changes: 34 additions & 0 deletions include/log4cpp/SyncOstreamAppender.hh
@@ -0,0 +1,34 @@
/*
* OstreamAppender.hh
*
* Copyright 2000, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
* Copyright 2000, Bastiaan Bakker. All rights reserved.
*
* See the COPYING file for the terms of usage and distribution.
*/

#ifndef _LOG4CPP_SYNCOSTREAMAPPENDER_HH
#define _LOG4CPP_SYNCOSTREAMAPPENDER_HH

#include <log4cpp/Portability.hh>
#include <string>
#include <iostream>
#include <log4cpp/LayoutAppender.hh>
#include <log4cpp/OstreamAppender.hh>

namespace log4cpp {

/**
* SyncOstreamAppender appends LoggingEvents to ostreams and flushes immediately.
**/
class LOG4CPP_EXPORT SyncOstreamAppender : public OstreamAppender {
public:
SyncOstreamAppender(const std::string& name, std::ostream* stream);
virtual ~SyncOstreamAppender();

protected:
virtual void _append(const LoggingEvent& event);
};
}

#endif // _LOG4CPP_SYNCOSTREAMAPPENDER_HH
33 changes: 33 additions & 0 deletions src/SyncOstreamAppender.cpp
@@ -0,0 +1,33 @@
/*
* SyncOstreamAppender.cpp
*
* Copyright 2013, Aupeo GmbH. All rights reserved.
*
* See the COPYING file for the terms of usage and distribution.
*/

#include "PortabilityImpl.hh"
#ifdef LOG4CPP_HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <log4cpp/SyncOstreamAppender.hh>

namespace log4cpp {

SyncOstreamAppender::SyncOstreamAppender(const std::string& name, std::ostream* stream) :
OstreamAppender(name, stream) {
}

SyncOstreamAppender::~SyncOstreamAppender() {
}

void SyncOstreamAppender::_append(const LoggingEvent& event) {
(*_stream) << _getLayout().format(event);
if (_stream->good()) {
(*_stream) << std::flush;
}
}
}
1 change: 1 addition & 0 deletions x86/so/Makefile
@@ -0,0 +1 @@
include ../../common.mk

0 comments on commit ff5d3b2

Please sign in to comment.