ILoggerObserver.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. // Special string in UST for determining if traces are empty
  15. constexpr char kEmptyTrace[] =
  16. "No Valid Trace Events (CPU/GPU) found. Outputting empty trace.";
  17. #if !USE_GOOGLE_LOG
  18. #include <map>
  19. #include <vector>
  20. #include <stdint.h>
  21. namespace libkineto {
  22. enum LoggerOutputType {
  23. VERBOSE = 0,
  24. INFO = 1,
  25. WARNING = 2,
  26. STAGE = 3,
  27. ERROR = 4,
  28. ENUM_COUNT = 5
  29. };
  30. const char* toString(LoggerOutputType t);
  31. LoggerOutputType toLoggerOutputType(const std::string& str);
  32. constexpr int LoggerTypeCount = (int)LoggerOutputType::ENUM_COUNT;
  33. class ILoggerObserver {
  34. public:
  35. virtual ~ILoggerObserver() = default;
  36. virtual void write(const std::string& message, LoggerOutputType ot) = 0;
  37. virtual const std::map<LoggerOutputType, std::vector<std::string>>
  38. extractCollectorMetadata() = 0;
  39. virtual void reset() = 0;
  40. virtual void addDevice(const int64_t device) = 0;
  41. virtual void setTraceDurationMS(const int64_t duration) = 0;
  42. virtual void addEventCount(const int64_t count) = 0;
  43. virtual void setTraceID(const std::string&) {}
  44. virtual void setGroupTraceID(const std::string&) {}
  45. virtual void addDestination(const std::string& dest) = 0;
  46. virtual void setTriggerOnDemand() {}
  47. virtual void addMetadata(
  48. const std::string& key,
  49. const std::string& value) = 0;
  50. };
  51. } // namespace libkineto
  52. #endif // !USE_GOOGLE_LOG