-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathConfig.java
More file actions
86 lines (75 loc) · 3.29 KB
/
Config.java
File metadata and controls
86 lines (75 loc) · 3.29 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package bark.client.models;
import bark.client.constants.Global;
import bark.client.requestchannel.ClientChannel;
import bark.client.services.ingestion.LogIngester;
import bark.client.services.sender.LogSender;
import java.io.IOException;
public class Config {
private String baseUrl;
private String errorLevel;
private String serviceName;
private String sessionName;
private Webhook webhook;
public void setAlertWebhook(Webhook webhook){
this.webhook = webhook;
}
public void Panic(String message) throws IOException {
System.out.println(message);
BarkLog log = new BarkLog(Global.Panic, this.serviceName, this.sessionName, Global.DefaultLogCode,message);
dispatchLogMessage(log);
}
public void Alert(String message) throws IOException {
System.out.println(message);
BarkLog log = new BarkLog(Global.Alert, this.serviceName, this.sessionName, Global.DefaultLogCode,message);
if(webhook!=null){
webhook.processWebhook(log);
}
dispatchLogMessage(log);
}
public void Error(String message) throws IOException {
System.out.println(message);
BarkLog log = new BarkLog(Global.Error, this.serviceName, this.sessionName, Global.DefaultLogCode,message);
dispatchLogMessage(log);
}
public void Warn(String message) throws IOException {
System.out.println(message);
BarkLog log = new BarkLog(Global.Warning, this.serviceName, this.sessionName, Global.DefaultLogCode,message);
dispatchLogMessage(log);
}
public void Notice(String message) throws IOException {
System.out.println(message);
BarkLog log = new BarkLog(Global.Notice, this.serviceName, this.sessionName, Global.DefaultLogCode,message);
dispatchLogMessage(log);
}
public void Info(String message) throws IOException {
System.out.println(message);
BarkLog log = new BarkLog(Global.Info, this.serviceName, this.sessionName, Global.DefaultLogCode,message);
dispatchLogMessage(log);
}
public void Debug(String message) throws IOException {
System.out.println(message);
BarkLog log = new BarkLog(Global.Debug, this.serviceName, this.sessionName, Global.DefaultLogCode,message);
dispatchLogMessage(log);
}
public void Raw(RawLog rawLog) throws IOException {
BarkLog log = new BarkLog(rawLog.getLogLevel(),rawLog.getServiceName(), rawLog.getSessionName(), rawLog.getCode(), rawLog.getMessage());
log.setMoreData(rawLog.getMoreData());
dispatchLogMessage(log);
}
public Config() {}
private Config(String baseUrl, String errorLevel, String serviceName, String sessionName) {
this.baseUrl = baseUrl;
this.errorLevel = errorLevel;
this.serviceName = serviceName;
this.sessionName = sessionName;
}
public static Config BarkClient(String baseUrl, String errorLevel, String serviceName, String sessionName) {
ClientChannel.createChannel();
LogSender logSender = new LogSender();
logSender.startSendingLogs(baseUrl);
return new Config(baseUrl,errorLevel,serviceName,sessionName);
}
private void dispatchLogMessage(BarkLog barkLog) throws IOException {
LogIngester.SendToClientChannel(barkLog);
}
}