mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 06:00:46 +00:00
Add LogToFile, closes #168
This commit is contained in:
@@ -77,6 +77,9 @@ namespace ArchiSteamFarm {
|
||||
[JsonProperty(Required = Required.DisallowNull)]
|
||||
internal ushort WCFPort { get; private set; } = 1242;
|
||||
|
||||
[JsonProperty(Required = Required.DisallowNull)]
|
||||
internal bool LogToFile { get; private set; } = true;
|
||||
|
||||
[JsonProperty(Required = Required.DisallowNull)]
|
||||
internal bool Statistics { get; private set; } = true;
|
||||
|
||||
|
||||
@@ -31,12 +31,10 @@ namespace ArchiSteamFarm {
|
||||
internal static class Logging {
|
||||
private static readonly object FileLock = new object();
|
||||
|
||||
internal static bool? LogToFile { get; set; } = null;
|
||||
private static bool LogToFile = false;
|
||||
|
||||
internal static void Init() {
|
||||
if (!LogToFile.HasValue) {
|
||||
LogToFile = true;
|
||||
}
|
||||
LogToFile = Program.GlobalConfig.LogToFile;
|
||||
|
||||
lock (FileLock) {
|
||||
try {
|
||||
@@ -123,7 +121,7 @@ namespace ArchiSteamFarm {
|
||||
} catch { }
|
||||
}
|
||||
|
||||
if (LogToFile.GetValueOrDefault()) {
|
||||
if (LogToFile) {
|
||||
lock (FileLock) {
|
||||
try {
|
||||
File.AppendAllText(Program.LogFile, loggedMessage);
|
||||
|
||||
@@ -371,13 +371,6 @@ namespace ArchiSteamFarm {
|
||||
switch (arg) {
|
||||
case "--client":
|
||||
Mode = EMode.Client;
|
||||
Logging.LogToFile = false;
|
||||
break;
|
||||
case "--log":
|
||||
Logging.LogToFile = true;
|
||||
break;
|
||||
case "--no-log":
|
||||
Logging.LogToFile = false;
|
||||
break;
|
||||
case "--server":
|
||||
Mode = EMode.Server;
|
||||
@@ -451,11 +444,11 @@ namespace ArchiSteamFarm {
|
||||
|
||||
// If debugging is on, we prepare debug directory prior to running
|
||||
if (GlobalConfig.Debug) {
|
||||
if (Directory.Exists(Program.DebugDirectory)) {
|
||||
Directory.Delete(Program.DebugDirectory, true);
|
||||
if (Directory.Exists(DebugDirectory)) {
|
||||
Directory.Delete(DebugDirectory, true);
|
||||
Thread.Sleep(1000); // Dirty workaround giving Windows some time to sync
|
||||
}
|
||||
Directory.CreateDirectory(Program.DebugDirectory);
|
||||
Directory.CreateDirectory(DebugDirectory);
|
||||
|
||||
SteamKit2.DebugLog.AddListener(new Debugging.DebugListener(Path.Combine(Program.DebugDirectory, "debug.txt")));
|
||||
SteamKit2.DebugLog.Enabled = true;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
"HttpTimeout": 60,
|
||||
"WCFHostname": "localhost",
|
||||
"WCFPort": 1242,
|
||||
"LogToFile": true,
|
||||
"Statistics": true,
|
||||
"HackIgnoreMachineID": false,
|
||||
"Blacklist": [
|
||||
|
||||
Reference in New Issue
Block a user