Skip to content
This repository has been archived by the owner on Jan 31, 2025. It is now read-only.

Commit

Permalink
Add ORBIT_LOG_VAR utility macro (#4856)
Browse files Browse the repository at this point in the history
  • Loading branch information
pierricgimmig authored Oct 19, 2023
1 parent b1c3258 commit 3493933
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/OrbitBase/include/OrbitBase/Logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ constexpr const char* kLogTimeFormat = "%Y-%m-%dT%H:%M:%E6S";
ORBIT_INTERNAL_PLATFORM_LOG(formatted_log__.c_str()); \
} while (0)

#define ORBIT_LOG_VAR(x) ORBIT_LOG("%s = %s", #x, orbit_base::to_string(x))

#define ORBIT_ERROR(format, ...) ORBIT_LOG("Error: " format, ##__VA_ARGS__)

#define ORBIT_LOG_ONCE(format, ...) \
Expand Down Expand Up @@ -162,6 +164,16 @@ ErrorMessageOr<void> TryRemoveOldLogFiles(const std::filesystem::path& log_dir);
void InitLogFile(const std::filesystem::path& path);

void LogStacktrace();

template <typename T>
inline std::string to_string(const T& value) {
return std::to_string(value);
}

inline std::string to_string(const std::string& value) { return value; }
inline std::string to_string(std::string_view value) { return std::string(value); }
inline std::string to_string(const char* value) { return value; }

} // namespace orbit_base

namespace orbit_base_internal {
Expand Down

0 comments on commit 3493933

Please sign in to comment.