message_initializer.cc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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/message_dictionary.h>
  15. #include <log/message_initializer.h>
  16. namespace isc {
  17. namespace log {
  18. // Constructor. Just retrieve the global dictionary and load the IDs and
  19. // associated text into it.
  20. MessageInitializer::MessageInitializer(const char* values[]) {
  21. MessageDictionary& global = MessageDictionary::globalDictionary();
  22. std::vector<std::string> repeats = global.load(values);
  23. // Append the IDs in the list just loaded (the "repeats") to the global list
  24. // of duplicate IDs.
  25. if (!repeats.empty()) {
  26. std::vector<std::string>& duplicates = getDuplicates();
  27. duplicates.insert(duplicates.end(), repeats.begin(), repeats.end());
  28. }
  29. }
  30. // Return reference to duplicate array
  31. std::vector<std::string>& MessageInitializer::getDuplicates() {
  32. static std::vector<std::string> duplicates;
  33. return (duplicates);
  34. }
  35. } // namespace log
  36. } // namespace isc