mirror of
https://github.com/RPCS3/discord-bot.git
synced 2026-01-31 01:25:22 +01:00
try to fix log path issues
This commit is contained in:
@@ -108,18 +108,20 @@ namespace CompatBot.Commands
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var log = File.Open(Config.LogPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
using (var result = new MemoryStream((int)Math.Min(Config.AttachmentSizeLimit, log.Length)))
|
||||
var logPath = Config.CurrentLogPath;
|
||||
var attachmentSizeLimit = Config.AttachmentSizeLimit;
|
||||
using (var log = File.Open(logPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
using (var result = new MemoryStream((int)Math.Min(attachmentSizeLimit, log.Length)))
|
||||
{
|
||||
using (var gzip = new GZipStream(result, CompressionLevel.Optimal, true))
|
||||
{
|
||||
await log.CopyToAsync(gzip, Config.Cts.Token).ConfigureAwait(false);
|
||||
await gzip.FlushAsync().ConfigureAwait(false);
|
||||
}
|
||||
if (result.Length <= Config.AttachmentSizeLimit)
|
||||
if (result.Length <= attachmentSizeLimit)
|
||||
{
|
||||
result.Seek(0, SeekOrigin.Begin);
|
||||
await ctx.RespondWithFileAsync(Path.GetFileName(Config.LogPath) + ".gz", result).ConfigureAwait(false);
|
||||
await ctx.RespondWithFileAsync(Path.GetFileName(logPath) + ".gz", result).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
await ctx.ReactWithAsync(Config.Reactions.Failure, "Compressed log size is too large, ask Nicba for help :(", true).ConfigureAwait(false);
|
||||
|
||||
@@ -55,9 +55,11 @@ namespace CompatBot
|
||||
public static int MinimumPiracyTriggerLength => config.GetValue(nameof(MinimumPiracyTriggerLength), 4);
|
||||
|
||||
public static string Token => config.GetValue(nameof(Token), "");
|
||||
public static string LogPath => config.GetValue(nameof(LogPath), "../../../logs/"); // paths are relative to the assembly, so this will put it in the project's root
|
||||
public static string LogPath => config.GetValue(nameof(LogPath), "./logs/"); // paths are relative to the working directory
|
||||
public static string IrdCachePath => config.GetValue(nameof(IrdCachePath), "./ird/");
|
||||
|
||||
internal static string CurrentLogPath => Path.GetFullPath(Path.Combine(LogPath, "bot.log"));
|
||||
|
||||
public static string GoogleApiConfigPath
|
||||
{
|
||||
get
|
||||
@@ -177,7 +179,7 @@ namespace CompatBot
|
||||
{
|
||||
var config = new NLog.Config.LoggingConfiguration();
|
||||
var fileTarget = new FileTarget("logfile") {
|
||||
FileName = Path.Combine(LogPath, "bot.log"),
|
||||
FileName = CurrentLogPath,
|
||||
ArchiveEvery = FileArchivePeriod.Day,
|
||||
ArchiveNumbering = ArchiveNumberingMode.DateAndSequence,
|
||||
KeepFileOpen = true,
|
||||
|
||||
Reference in New Issue
Block a user