-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLoggerServiceConfig.cs
More file actions
53 lines (45 loc) · 1.52 KB
/
LoggerServiceConfig.cs
File metadata and controls
53 lines (45 loc) · 1.52 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
using System.IO;
using com.mapcolonies.core.Utilities;
using Cysharp.Threading.Tasks;
using Newtonsoft.Json;
using UnityEngine;
namespace com.mapcolonies.core.Services.LoggerService
{
public class LoggerServiceConfig
{
private const string JsonFileName = "Logger/LoggerConfig.json";
public LoggerSettings Settings
{
get;
private set;
}
public void Init()
{
try
{
Settings = JsonUtilityEx.LoadJson<LoggerSettings>(JsonFileName);
if (Settings == null)
{
Debug.LogError($"Failed to deserialize {JsonFileName} JSON content.");
}
}
catch (System.Exception ex)
{
Debug.LogError($"Error loading {JsonFileName}: {ex.Message}");
}
}
public string GetSystemLogsDirectory()
{
if (Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsEditor)
{
return Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData), Application.companyName, Application.productName, "logs");
}
return Application.persistentDataPath;
}
public string GetHttpPersistenceDirectory()
{
string baseLogsDirectory = GetSystemLogsDirectory();
return Path.Combine(baseLogsDirectory, "offline");
}
}
}