StringQueueAppender.cpp
Go to the documentation of this file.
00001 /*
00002  * StringQueueAppender.cpp
00003  *
00004  * Copyright 2000, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
00005  * Copyright 2000, Bastiaan Bakker. All rights reserved.
00006  *
00007  * See the COPYING file for the terms of usage and distribution.
00008  */
00009 
00010 #include "PortabilityImpl.hh"
00011 #include <log4cpp/StringQueueAppender.hh>
00012 
00013 namespace log4cpp {
00014 
00015     StringQueueAppender::StringQueueAppender(const std::string& name) : 
00016         LayoutAppender(name) {
00017     }
00018     
00019     StringQueueAppender::~StringQueueAppender() {
00020         close();
00021     }
00022 
00023     void StringQueueAppender::close() {
00024         // empty
00025     }
00026 
00027     void StringQueueAppender::_append(const LoggingEvent& event) {
00028         _queue.push(_getLayout().format(event));
00029     }
00030 
00031     bool StringQueueAppender::reopen() {
00032         return true;
00033     }      
00034 
00035     std::queue<std::string>& StringQueueAppender::getQueue() {
00036         return _queue;
00037     }
00038 
00039     const std::queue<std::string>& StringQueueAppender::getQueue() const {
00040         return _queue;
00041     }
00042 
00043     size_t StringQueueAppender::queueSize() const {
00044         return getQueue().size();
00045     }
00046 
00047     std::string StringQueueAppender::popMessage() {        
00048         std::string message;
00049 
00050         if (!_queue.empty()) {
00051             message = _queue.front();
00052             _queue.pop();
00053         }
00054 
00055         return message;
00056     }
00057 }


log4cpp
Author(s): Stephen Roderick, Bastiaan Bakker, Cedric Le Goater, Steve Ostlind, Marcel Harkema, Walter Stroebel, Glenn Scott and Tony Cheung
autogenerated on Sat Jun 8 2019 18:45:46