logger_name.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. #ifndef __LOGGER_NAME_H
  15. #define __LOGGER_NAME_H
  16. #include <string>
  17. /// \brief Define Name of Root Logger
  18. ///
  19. /// In BIND-10, the name root logger of a program is the name of the program
  20. /// itself (in contrast to packages such as log4cplus where the root logger name
  21. // is something like "root"). These trivial functions allow the setting and
  22. // getting of that name by the logger classes.
  23. namespace isc {
  24. namespace log {
  25. /// \brief Set root logger name
  26. ///
  27. /// This function should be called by the program's initialization code before
  28. /// any logging functions are called.
  29. ///
  30. /// \param name Name of the root logger. This should be the program name.
  31. void setRootLoggerName(const std::string& name);
  32. /// \brief Get root logger name
  33. ///
  34. /// \return Name of the root logger.
  35. const std::string& getRootLoggerName();
  36. /// \brief Expand logger name
  37. ///
  38. /// Given a logger name, returns the fully-expanded logger name. If the name
  39. /// starts with the root logger name, it is returned as-is. Otherwise it is
  40. /// prefixed with the root logger name.
  41. ///
  42. /// \param name Name to expand.
  43. ///
  44. /// \return Fully-expanded logger name.
  45. std::string expandLoggerName(const std::string& name);
  46. }
  47. }
  48. #endif // __LOGGER_NAME_H