namespace detail {
- SENF_CONSOLE_REGISTER_ENUM_MEMBER( TargetRegistry, Level,
+ SENF_CONSOLE_REGISTER_ENUM_MEMBER( TargetRegistry, Level,
(VERBOSE)(NOTICE)(MESSAGE)(IMPORTANT)(CRITICAL)(FATAL) );
}}}
detail::TargetRegistry::instance().registerTarget(this, name);
consoleDir_()
- .add("list", fty::Command(this, &Target::consoleList)
+ .add("list", fty::Command(&Target::consoleList, this)
.doc("Show routing table\n"
"\n"
"Columns:\n"
" LEVEL match messages with level above this. Log levels in increasing order\n"
" are:\n"
" verbose, notice, message, important, critical, fatal\n"
+ " If the log level is listed as 'default', the streams default limit\n"
+ " applies.\n"
" ACTION action to take: accept or reject") );
consoleDir_()
- .add("route", fty::Command(this, &Target::consoleRoute)
+ .add("route", fty::Command(&Target::consoleRoute, this)
.arg("index", "index at which to insert new rule")
.arg("parameters", "log parameters. The log parameters select the log stream, log area\n"
" and log level. You may specify any combination of these parameterse\n"
"Examples:\n"
"\n"
" route ()\n"
- " route all messages to this target.\n"
+ " route all messages with level above each streams default log limit to this\n"
+ " target.\n"
"\n"
- " route 1 (my::Class)\n"
+ " route 1 (my::Class VERBOSE)\n"
" route all messages which are in the my::Class area. Insert this route after\n"
" the first route,\n"
"\n"
.arg("action", kw::default_value=ACCEPT) );
consoleDir_()
.add("unroute",
- fty::Command(this, static_cast<void (Target::*)(int)>(&Target::unroute))
+ fty::Command(static_cast<void (Target::*)(int)>(&Target::unroute), this)
.arg("index", "index of routing entry to remove")
.overloadDoc("Remove routing entry with the given index") );
consoleDir_()
- .add("unroute", fty::Command(this, &Target::consoleUnroute)
+ .add("unroute", fty::Command(&Target::consoleUnroute, this)
.arg("parameters", "log parameters. The log parameters select the log stream, log area\n"
- " and log level. You may specify any combination of these parameterse\n"
+ " and log level. You may specify any combination of these parameters\n"
" in any order. Use the '/sys/log/stream' and '/sys/log/areas' commands\n"
" to list all valid streams and areas. Valid log levels are:\n"
" VERBOSE NOTICE MESSAGE IMPORTANT CRITICAL FATAL")
kw::default_value=ACCEPT)
.overloadDoc("Remove the routing entry matching the specified arguments.") );
consoleDir_()
- .add("flush", fty::Command(this, &Target::flush)
+ .add("flush", fty::Command(&Target::flush, this)
.doc("Remove all routing entries clearing the routing table. This will disable all\n"
"logging output on this target.") );
}
return l.substr(l.size()-29);
return l;
}
+
+ char const * levelNames[] = {
+ "NONE", "VERBOSE", "NOTICE", "MESSAGE", "IMPORTANT", "CRITICAL", "FATAL", "DISABLED" };
+
+ char const * levelNamesList[] = {
+ "default", "verbose", "notice", "message", "important", "critical", "fatal", "disabled" };
}
prefix_ void senf::log::Target::consoleList(std::ostream & os)
{
- static char const * levels[] = {
- "verbose", "verbose", "notice", "message", "important", "critical", "fatal", "disabled" };
boost::format fmt ("%2d %-29s %-29s %-9s %-6s\n");
os << fmt % "#" % "STREAM" % "AREA" % "LEVEL" % "ACTION";
unsigned n (0);
for (iterator i (begin()); i != end(); ++i, ++n)
- os << fmt
- % n
+ os << fmt
+ % n
% formatLabel(i->stream())
% formatLabel(i->area())
- % levels[i->level()]
+ % levelNamesList[i->level()]
% (i->action() == ACCEPT ? "accept" : "reject");
}
console::sysdir().add("log", consoleDir_());
consoleDir_()
- .add("areas", fty::Command(this, &TargetRegistry::consoleAreas)
+ .add("areas", fty::Command(&TargetRegistry::consoleAreas, this)
.doc("List all areas") );
consoleDir_()
- .add("streams", fty::Command(this, &TargetRegistry::consoleStreams)
- .doc("List all streams") );
+ .add("streams", fty::Command(&TargetRegistry::consoleStreams, this)
+ .doc("List all streams with the streams default runtime log level limit.") );
consoleDir_()
- .add("message", fty::Command(this, &TargetRegistry::consoleWrite)
+ .add("message", fty::Command(&TargetRegistry::consoleWrite, this)
.arg("parameters", "log parameters. The log parameters select the log stream, log area\n"
" and log level. You may specify any combination of these parameterse\n"
" in any order. Use the '/sys/log/stream' and '/sys/log/areas' commands\n"
" message (FATAL) \"Program on fire\";\n"
" message (VERBOSE senf::log::Debug) \"Debug message\";") );
consoleDir_()
- .add("self", fty::Command(this, &TargetRegistry::consoleSelf)
+ .add("self", fty::Command(&TargetRegistry::consoleSelf, this)
.doc("Get the log directory of the current network client. Example usage:\n"
"\n"
"Just get the log config directory\n"
{
StreamRegistry::iterator i (StreamRegistry::instance().begin());
StreamRegistry::iterator const i_end (StreamRegistry::instance().end());
- for (; i != i_end; ++i)
- os << *i << "\n";
+ for (; i != i_end; ++i) {
+ os << *i << " "
+ << levelNames[StreamRegistry::instance().lookup(*i)->defaultRuntimeLimit()] << "\n";
+ }
}
prefix_ void senf::log::detail::TargetRegistry::consoleWrite(LogParameters pm,
senf::log::detail::TargetRegistry::consoleSelf(std::ostream & os)
{
return senf::console::Client::get(os).consoleDir().node().thisptr();
-}
+}
///////////////////////////////////////////////////////////////////////////
// senf::log::detail::LogParameters
namespace {
- char const * levelNames[] = {
- "NONE", "VERBOSE", "NOTICE", "MESSAGE", "IMPORTANT", "CRITICAL", "FATAL", "DISABLED" };
-
void parseParamToken(std::string const & value, senf::log::detail::LogParameters & out)
{
senf::log::detail::StreamBase const * s (
out.area = a;
return;
}
-
+
char const ** i (
std::find(levelNames+1, levelNames+sizeof(levelNames)/sizeof(levelNames[0])-1, value));
if (i == levelNames+sizeof(levelNames)/sizeof(levelNames[0])-1)
LogParameters & out)
{
out.clear();
-
+
for (console::ParseCommandInfo::TokensRange::iterator i (tokens.begin());
i != tokens.end(); ++i)
parseParamToken(i->value(), out);