fix: Makes logging more consistent (#1246)
This commit is contained in:
parent
8e0d01d4be
commit
d8cfb6b935
15 changed files with 90 additions and 69 deletions
|
|
@ -51,17 +51,17 @@ namespace Server.Configurations
|
|||
|
||||
if (settings == null)
|
||||
{
|
||||
logger.Error($"Failed reading email configuration from {m_RelPath}");
|
||||
logger.Error("Failed reading email configuration from {Path}", m_RelPath);
|
||||
throw new JsonException($"Failed to deserialize {path}.");
|
||||
}
|
||||
|
||||
logger.Information($"Email configuration read from {m_RelPath}");
|
||||
logger.Information("Email configuration read from {Path}", m_RelPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
settings = new Settings();
|
||||
JsonConfig.Serialize(path, settings);
|
||||
logger.Information($"Email configuration saved to {m_RelPath}.");
|
||||
logger.Information("Email configuration saved to {}.", m_RelPath);
|
||||
}
|
||||
|
||||
EmailEnabled = settings.enabled;
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ namespace Server.Engines.Spawners
|
|||
{
|
||||
var file = files[i];
|
||||
from.SendMessage("GenerateSpawners: Generating spawners from {0}...", file.Name);
|
||||
logger.Information($"{from} is generating spawners from {file.FullName}");
|
||||
logger.Information("{User} is generating spawners from {File}", from, file.FullName);
|
||||
|
||||
NetState.FlushAll();
|
||||
|
||||
|
|
@ -213,7 +213,7 @@ namespace Server.Engines.Spawners
|
|||
}
|
||||
|
||||
#if DEBUG
|
||||
logger.Error($"{message}\n{ex}");
|
||||
logger.Error(ex, message);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,9 @@ namespace Server.Misc
|
|||
if (MinRequired != null || MaxRequired != null)
|
||||
{
|
||||
logger.Information(
|
||||
$"Restricting client version to {GetVersionExpression()}. Action to be taken: {_invalidClientResponse}"
|
||||
"Restricting client version to {ClientVersion}. Action to be taken: {Action}",
|
||||
GetVersionExpression(),
|
||||
_invalidClientResponse
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,11 +112,11 @@ namespace Server.Misc
|
|||
DirectoryCopy(savePath, backupPath);
|
||||
}
|
||||
|
||||
logger.Information("Backup done");
|
||||
logger.Information("Backup {Status}", "done");
|
||||
}
|
||||
catch
|
||||
{
|
||||
logger.Error("Backup failed");
|
||||
logger.Error("Backup {Status}", "failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ namespace Server.Saves
|
|||
var backupPath = Path.Combine(AutomaticBackupPath, Utility.GetTimeStamp());
|
||||
PathUtility.MoveDirectory(args.OldSavePath, backupPath);
|
||||
|
||||
logger.Information($"Created backup at {backupPath}");
|
||||
logger.Information("Created backup at {Path}", backupPath);
|
||||
|
||||
Archive?.Invoke();
|
||||
}
|
||||
|
|
@ -132,7 +132,7 @@ namespace Server.Saves
|
|||
return false;
|
||||
}
|
||||
|
||||
logger.Information($"Restoring latest world save from archive {fileName}");
|
||||
logger.Information("Restoring latest world save from archive {File}", fileName);
|
||||
|
||||
var tempPath = PathUtility.EnsureRandomPath(_tempArchivePath);
|
||||
var successful = fileName.EndsWithOrdinal(".tar.zst")
|
||||
|
|
@ -141,7 +141,7 @@ namespace Server.Saves
|
|||
|
||||
if (!successful)
|
||||
{
|
||||
logger.Information($"Failed to extract {fi.Name}");
|
||||
logger.Information("Failed to extract {File}", fi.Name);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -149,7 +149,7 @@ namespace Server.Saves
|
|||
{
|
||||
Directory.Delete(savePath, true);
|
||||
var dirInfo = new DirectoryInfo(folder);
|
||||
logger.Information($"Restoring backup {dirInfo.Name}");
|
||||
logger.Information("Restoring backup {Directory}", dirInfo.Name);
|
||||
PathUtility.MoveDirectory(folder, savePath);
|
||||
break;
|
||||
}
|
||||
|
|
@ -188,7 +188,7 @@ namespace Server.Saves
|
|||
|
||||
if (date < threshold)
|
||||
{
|
||||
logger.Information($"Pruning old backup {folder}");
|
||||
logger.Information("Pruning old backup {Directory}", folder);
|
||||
Directory.Delete(folder, true);
|
||||
}
|
||||
}
|
||||
|
|
@ -213,7 +213,7 @@ namespace Server.Saves
|
|||
}
|
||||
|
||||
var fi = new FileInfo(archive);
|
||||
logger.Information($"Pruning {periodLowerStr} archive {fi.Name}");
|
||||
logger.Information("Pruning {Period} archive {File}", periodLowerStr, fi.Name);
|
||||
File.Delete(archive);
|
||||
}
|
||||
}
|
||||
|
|
@ -331,7 +331,12 @@ namespace Server.Saves
|
|||
if (archiveCreated)
|
||||
{
|
||||
var elapsed = stopWatch.Elapsed.TotalSeconds;
|
||||
logger.Information($"Created {archivePeriodStrLower} archive at {archiveFilePath} ({elapsed:F2} seconds)");
|
||||
logger.Information(
|
||||
"Created {Period} archive at {Path} ({Elapsed:F2} seconds)",
|
||||
archivePeriodStrLower,
|
||||
archiveFilePath,
|
||||
elapsed
|
||||
);
|
||||
|
||||
var i = minimum;
|
||||
foreach (var backup in backups)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue