IOStreamTarget.cc
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
17 #include "IOStreamTarget.hh"
18 //#include "IOStreamTarget.ih"
19 
20 // Custom includes
21 #include <boost/algorithm/string/trim.hpp>
22 #include <boost/tokenizer.hpp>
23 
24 //#include "IOStreamTarget.mpp"
25 #define prefix_
26 //-/////////////////////////////////////////////////////////////////////////////////////////////////
27 
28 //-/////////////////////////////////////////////////////////////////////////////////////////////////
29 // senf::log::IOStreamTarget
30 
32  std::string const & stream,
33  std::string const & area, unsigned level,
34  std::string const & message)
35 {
36  std::string m (message);
37  boost::trim_right(m);
39 
40  if (isPlainFormat())
41  *stream_ << m << std::endl;
42  else {
43  std::string const & prf (prefix(timestamp, stream, area, level));
44 
45  typedef boost::char_separator<char> Separator;
46  typedef boost::tokenizer<Separator> Tokenizer;
47  Separator separator ("\n");
48  Tokenizer tokenizer (m, separator);
49  Tokenizer::iterator i (tokenizer.begin());
50  Tokenizer::iterator const i_end (tokenizer.end());
51 
52  for (; i != i_end; ++i)
53  *stream_ << prf << *i << "\n";
54  *stream_ << std::flush;
55  }
56 }
57 
58 //-/////////////////////////////////////////////////////////////////////////////////////////////////
59 #undef prefix_
60 //#include "IOStreamTarget.mpp"
61 
62 
63 // Local Variables:
64 // mode: c++
65 // fill-column: 100
66 // comment-column: 40
67 // c-file-style: "senf"
68 // indent-tabs-mode: nil
69 // ispell-local-dictionary: "american"
70 // compile-command: "scons -u test"
71 // End:
void quoteNonPrintable(std::string &s)
Definition: LogFormat.cc:140
void v_write(time_type timestamp, std::string const &stream, std::string const &area, unsigned level, std::string const &message)
Called to write out the routing message.
IOStreamTarget public header.
std::string prefix(time_type timestamp, std::string const &stream, std::string const &area, unsigned level)
Definition: LogFormat.cc:108
config::time_type time_type
Definition: TimeSource.hh:31
#define prefix_