-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathLokiLogger.hpp
49 lines (35 loc) · 1012 Bytes
/
LokiLogger.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once
#include <HTTPClient.h>
#include <Print.h>
#include "weatherBridge/arrayExtensions.hpp"
class LokiLogger {
private:
static constexpr char lokiRequestBodyTemplate[] = R"json(
{
"streams": [
{
"stream": {
"project": "%s",
"deviceId": "%s"
},
"values": [
[ "%s", "%s" ]
]
}
]
})json";
static constexpr char projectLabel[] = "weather-exporter";
String lokiCompleteUrl = "";
String username = "";
String password = "";
bool isEnabled = false;
LokiLogger();
public:
static LokiLogger Instance;
static void beginNoop();
static void begin(const String &lokiUrl, const String &lokiUsername, const String& lokiPassword);
void writeLog(const String &line);
private:
void sendToLoki(const char *buffer, size_t size);
static String escapeJson(const char *buffer, size_t size);
};