master
h 30 lines 995 Bytes
Raw
1 // Copyright (C) Microsoft Corporation. All rights reserved.
2 #pragma once
3
4 namespace p9fs {
5
6 // Class to help construct tracelogging messages for verbose logging of server traffic.
7 // N.B. To avoid needlessly increasing the size of the statically linked WSL init binary, this
8 // helper allows for constructing log messages without the use of printf or iostream.
9 class LogMessageBuilder
10 {
11 public:
12 void AddName(std::string_view name);
13 void AddField(std::string_view name, std::string_view value);
14 void AddField(std::string_view name, UINT64 value, int base = 10);
15 void AddField(std::string_view name, const Qid& value);
16 void AddValue(std::string_view value);
17 void AddValue(const Qid& qid);
18
19 const char* String() const;
20
21 private:
22 void AddFieldName(std::string_view name);
23 void AddRawValue(UINT64 value, int base = 10);
24 void AddRawValue(const Qid& value);
25 void AddRawValue(std::string_view value);
26
27 std::string m_message;
28 };
29
30 } // namespace p9fs