-
-
Notifications
You must be signed in to change notification settings - Fork 265
Expand file tree
/
Copy pathLogManager.cs
More file actions
41 lines (37 loc) · 1.19 KB
/
LogManager.cs
File metadata and controls
41 lines (37 loc) · 1.19 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
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace AIProgrammer.Managers
{
public static class LogManager
{
/// <summary>
/// Logs a message to the logging web service Loggly.
/// </summary>
/// <param name="message">string</param>
/// <param name="tag">string</param>
/// <param name="logglyKey">Loggly API key</param>
public static string Log(string message, string tag, string logglyKey)
{
string result = "";
try
{
string url = "https://logs-01.loggly.com/inputs/" + logglyKey + "/tag/" + tag.Replace(" ", "_") + "/";
using (WebClient client = new WebClient())
{
byte[] response = client.UploadValues(url, new NameValueCollection() { { "Message", message } });
result = Encoding.UTF8.GetString(response);
}
}
catch (Exception ex)
{
result = ex.ToString();
}
return result;
}
}
}