4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief StatisticsTargets non-inline non-template implementation */
26 #include "StatisticsTargets.hh"
27 #include "StatisticsTargets.ih"
30 #include <boost/bind.hpp>
31 #include <senf/Utils/Console/Console.hh>
32 #include "Statistics.hh"
34 //#include "StatisticsTargets.mpp"
36 ///////////////////////////////cc.p////////////////////////////////////////
38 ///////////////////////////////////////////////////////////////////////////
39 // senf::detail::StatisticsLoggerRegistry
42 senf::detail::StatisticsLoggerRegistry::apply(senf::StatisticsBase & stats,
44 senf::console::DirectoryNode & dir)
46 Adders::const_iterator i (adders_.begin());
47 Adders::const_iterator const i_end (adders_.end());
48 for (; i != i_end; ++i)
49 (*i)(stats, rank, dir);
52 ///////////////////////////////////////////////////////////////////////////
56 struct RegisterStatisticsLogger
58 RegisterStatisticsLogger();
60 static void adder(senf::StatisticsBase & stats,
62 senf::console::DirectoryNode & dir);
64 static void consoleCreate(senf::StatisticsBase & stats,
66 std::string const & prefix);
69 RegisterStatisticsLogger registerStatisticsLogger;
72 prefix_ RegisterStatisticsLogger::RegisterStatisticsLogger()
74 senf::detail::StatisticsLoggerRegistry::instance().add(&adder);
77 prefix_ void RegisterStatisticsLogger::adder(senf::StatisticsBase & stats,
79 senf::console::DirectoryNode & dir)
81 namespace kw = senf::console::kw;
82 namespace fty = senf::console::factory;
84 dir.add("logger", fty::Command<void (std::string const &)>(
85 boost::bind(&consoleCreate, boost::ref(stats), rank, _1))
86 .arg("prefix","Optional prefix string to add to each log message",
87 kw::default_value = "")
88 .doc("Send log messages to statistics log stream") );
91 prefix_ void RegisterStatisticsLogger::consoleCreate(senf::StatisticsBase & stats,
93 std::string const & prefix)
95 stats.output(rank).connect(senf::StatisticsLogger(prefix),
96 "senf::StatisticsLogger(\"" + prefix + "\")");
99 ///////////////////////////////cc.e////////////////////////////////////////
101 //#include "StatisticsTargets.mpp"
107 // comment-column: 40
108 // c-file-style: "senf"
109 // indent-tabs-mode: nil
110 // ispell-local-dictionary: "american"
111 // compile-command: "scons -u test"