00001 // $Id: IOStreamTarget.cc 1757 2011-01-06 16:52:09Z tho $ 00002 // 00003 // Copyright (C) 2007 00004 // Fraunhofer (FOKUS) 00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY 00006 // Stefan Bund <g0dil@berlios.de> 00007 // 00008 // This program is free software; you can redistribute it and/or modify 00009 // it under the terms of the GNU General Public License as published by 00010 // the Free Software Foundation; either version 2 of the License, or 00011 // (at your option) any later version. 00012 // 00013 // This program is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 // GNU General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU General Public License 00019 // along with this program; if not, write to the 00020 // Free Software Foundation, Inc., 00021 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00022 00026 #include "IOStreamTarget.hh" 00027 //#include "IOStreamTarget.ih" 00028 00029 // Custom includes 00030 #include <boost/algorithm/string/trim.hpp> 00031 #include <boost/tokenizer.hpp> 00032 00033 //#include "IOStreamTarget.mpp" 00034 #define prefix_ 00035 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00036 00037 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00038 // senf::log::IOStreamTarget 00039 00040 prefix_ void senf::log::IOStreamTarget::v_write(time_type timestamp, 00041 std::string const & stream, 00042 std::string const & area, unsigned level, 00043 std::string const & message) 00044 { 00045 std::string m (message); 00046 boost::trim_right(m); 00047 detail::quoteNonPrintable(m); 00048 00049 if (isPlainFormat()) 00050 stream_ << m << std::endl; 00051 else { 00052 std::string const & prf (prefix(timestamp, stream, area, level)); 00053 00054 typedef boost::char_separator<char> Separator; 00055 typedef boost::tokenizer<Separator> Tokenizer; 00056 Separator separator ("\n"); 00057 Tokenizer tokenizer (m, separator); 00058 Tokenizer::iterator i (tokenizer.begin()); 00059 Tokenizer::iterator const i_end (tokenizer.end()); 00060 00061 for (; i != i_end; ++i) 00062 stream_ << prf << *i << "\n"; 00063 stream_ << std::flush; 00064 } 00065 } 00066 00067 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00068 #undef prefix_ 00069 //#include "IOStreamTarget.mpp" 00070 00071 00072 // Local Variables: 00073 // mode: c++ 00074 // fill-column: 100 00075 // comment-column: 40 00076 // c-file-style: "senf" 00077 // indent-tabs-mode: nil 00078 // ispell-local-dictionary: "american" 00079 // compile-command: "scons -u test" 00080 // End: