Commit 0692e63e authored by Jelte Jansen's avatar Jelte Jansen
Browse files

[trac555] move getDestination to logger_level

parent c9d69c54
......@@ -12,11 +12,11 @@ liblog_la_SOURCES += log_formatter.h log_formatter.cc
liblog_la_SOURCES += logger.cc logger.h
liblog_la_SOURCES += logger_impl.cc logger_impl.h
liblog_la_SOURCES += logger_level.h
liblog_la_SOURCES += logger_level.h
liblog_la_SOURCES += logger_level.cc logger_level.h
liblog_la_SOURCES += logger_level_impl.cc logger_level_impl.h
liblog_la_SOURCES += logger_manager.cc logger_manager.h
liblog_la_SOURCES += logger_manager_impl.cc logger_manager_impl.h
liblog_la_SOURCES += logger_specification.cc logger_specification.h
liblog_la_SOURCES += logger_specification.h
liblog_la_SOURCES += logger_support.cc logger_support.h
liblog_la_SOURCES += macros.h
liblog_la_SOURCES += messagedef.cc messagedef.h
......
......@@ -12,7 +12,7 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE
#include <log/logger_specification.h>
#include <log/logger_level.h>
#include <log/macros.h>
#include <log/messagedef.h>
......
......@@ -15,6 +15,8 @@
#ifndef __LOGGER_LEVEL_H
#define __LOGGER_LEVEL_H
#include <string>
namespace isc {
namespace log {
......@@ -56,6 +58,18 @@ struct Level {
// Default assignment and copy constructor is appropriate
};
/// \brief Returns the isc::log::Severity value represented by the
/// given string
///
/// If the string is not recognized, returns isc::log::DEBUG.
/// This must be one of the strings "DEBUG", "INFO", "WARN", "ERROR",
/// "FATAL". (Must be upper case and must not contain leading or
/// trailing spaces.)
///
/// \param sev_str The string representing severity value
/// \return The severity
isc::log::Severity getSeverity(const std::string& sev_str);
} // namespace log
} // namespace isc
......
......@@ -150,18 +150,6 @@ private:
std::vector<OutputOption> options_; ///< Logger options
};
/// \brief Returns the isc::log::Severity value represented by the
/// given string
///
/// If the string is not recognized, returns isc::log::DEBUG.
/// This must be one of the strings "DEBUG", "INFO", "WARN", "ERROR",
/// "FATAL". (Must be upper case and must not contain leading or
/// trailing spaces.)
///
/// \param sev_str The string representing severity value
/// \return The severity
isc::log::Severity getSeverity(const std::string& sev_str);
} // namespace log
} // namespace isc
......
......@@ -54,3 +54,25 @@ TEST_F(LoggerLevelTest, Creation) {
EXPECT_EQ(isc::log::DEBUG, level3.severity);
EXPECT_EQ(42, level3.dbglevel);
}
TEST(LoggerLevel, getSeverity) {
EXPECT_EQ(DEBUG, getSeverity("DEBUG"));
EXPECT_EQ(DEBUG, getSeverity("debug"));
EXPECT_EQ(DEBUG, getSeverity("DeBuG"));
EXPECT_EQ(INFO, getSeverity("INFO"));
EXPECT_EQ(INFO, getSeverity("info"));
EXPECT_EQ(INFO, getSeverity("iNfO"));
EXPECT_EQ(WARN, getSeverity("WARN"));
EXPECT_EQ(WARN, getSeverity("warn"));
EXPECT_EQ(WARN, getSeverity("wARn"));
EXPECT_EQ(ERROR, getSeverity("ERROR"));
EXPECT_EQ(ERROR, getSeverity("error"));
EXPECT_EQ(ERROR, getSeverity("ERRoR"));
EXPECT_EQ(FATAL, getSeverity("FATAL"));
EXPECT_EQ(FATAL, getSeverity("fatal"));
EXPECT_EQ(FATAL, getSeverity("FAtaL"));
// bad values should default to stdout
EXPECT_EQ(INFO, getSeverity("some bad value"));
EXPECT_EQ(INFO, getSeverity(""));
}
......@@ -104,26 +104,3 @@ TEST_F(LoggerSpecificationTest, AddOption) {
++i;
EXPECT_TRUE(i == spec.end());
}
TEST(LoggerSpecification, getSeverity) {
EXPECT_EQ(DEBUG, getSeverity("DEBUG"));
EXPECT_EQ(DEBUG, getSeverity("debug"));
EXPECT_EQ(DEBUG, getSeverity("DeBuG"));
EXPECT_EQ(INFO, getSeverity("INFO"));
EXPECT_EQ(INFO, getSeverity("info"));
EXPECT_EQ(INFO, getSeverity("iNfO"));
EXPECT_EQ(WARN, getSeverity("WARN"));
EXPECT_EQ(WARN, getSeverity("warn"));
EXPECT_EQ(WARN, getSeverity("wARn"));
EXPECT_EQ(ERROR, getSeverity("ERROR"));
EXPECT_EQ(ERROR, getSeverity("error"));
EXPECT_EQ(ERROR, getSeverity("ERRoR"));
EXPECT_EQ(FATAL, getSeverity("FATAL"));
EXPECT_EQ(FATAL, getSeverity("fatal"));
EXPECT_EQ(FATAL, getSeverity("FAtaL"));
// bad values should default to stdout
EXPECT_EQ(INFO, getSeverity("some bad value"));
EXPECT_EQ(INFO, getSeverity(""));
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment