ILoggerObserver.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (c) Meta Platforms, Inc. and affiliates.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree.
  7. */
  8. #pragma once
  9. #include <string>
  10. // Stages in libkineto used when pushing logs to UST Logger.
  11. constexpr char kWarmUpStage[] = "Warm Up";
  12. constexpr char kCollectionStage[] = "Collection";
  13. constexpr char kPostProcessingStage[] = "Post Processing";
  14. #if !USE_GOOGLE_LOG
  15. #include <map>
  16. #include <vector>
  17. #include <stdint.h>
  18. namespace libkineto {
  19. enum LoggerOutputType {
  20. VERBOSE = 0,
  21. INFO = 1,
  22. WARNING = 2,
  23. STAGE = 3,
  24. ERROR = 4,
  25. ENUM_COUNT = 5
  26. };
  27. const char* toString(LoggerOutputType t);
  28. LoggerOutputType toLoggerOutputType(const std::string& str);
  29. constexpr int LoggerTypeCount = (int) LoggerOutputType::ENUM_COUNT;
  30. class ILoggerObserver {
  31. public:
  32. virtual ~ILoggerObserver() = default;
  33. virtual void write(const std::string& message, LoggerOutputType ot) = 0;
  34. virtual const std::map<LoggerOutputType, std::vector<std::string>> extractCollectorMetadata() = 0;
  35. virtual void reset() = 0;
  36. virtual void addDevice(const int64_t device) = 0;
  37. virtual void setTraceDurationMS(const int64_t duration) = 0;
  38. virtual void addEventCount(const int64_t count) = 0;
  39. virtual void setTraceID(const std::string&) {}
  40. virtual void setGroupTraceID(const std::string&) {}
  41. virtual void addDestination(const std::string& dest) = 0;
  42. virtual void setTriggerOnDemand() {}
  43. virtual void addMetadata(const std::string& key, const std::string& value) = 0;
  44. };
  45. } // namespace libkineto
  46. #endif // !USE_GOOGLE_LOG