logger_level.cc 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE
  14. #include <log/logger_level.h>
  15. #include <log/macros.h>
  16. #include <log/log_messages.h>
  17. #include <boost/algorithm/string.hpp>
  18. namespace isc {
  19. namespace log {
  20. isc::log::Severity
  21. getSeverity(const std::string& sev_str) {
  22. if (boost::iequals(sev_str, "DEBUG")) {
  23. return isc::log::DEBUG;
  24. } else if (boost::iequals(sev_str, "INFO")) {
  25. return isc::log::INFO;
  26. } else if (boost::iequals(sev_str, "WARN")) {
  27. return isc::log::WARN;
  28. } else if (boost::iequals(sev_str, "ERROR")) {
  29. return isc::log::ERROR;
  30. } else if (boost::iequals(sev_str, "FATAL")) {
  31. return isc::log::FATAL;
  32. } else if (boost::iequals(sev_str, "NONE")) {
  33. return isc::log::NONE;
  34. } else {
  35. Logger logger("log");
  36. LOG_ERROR(logger, LOG_BAD_SEVERITY).arg(sev_str);
  37. return isc::log::INFO;
  38. }
  39. }
  40. } // namespace log
  41. } // namespace isc