diff --git a/DiscordConnector/Logger.cs b/DiscordConnector/Logger.cs
index 23d6125..b83a812 100644
--- a/DiscordConnector/Logger.cs
+++ b/DiscordConnector/Logger.cs
@@ -26,9 +26,44 @@ private void InitializeLogFile()
{
if (File.Exists(_logFilePath))
{
- string oldLogFilePath = $"{_logFilePath}.old";
- File.Move(_logFilePath, oldLogFilePath);
- _logger.LogInfo($"Existing log file moved to {oldLogFilePath}");
+ // versions old logs, like log.1 log.2 (up to 5)
+ for (int i = 5; i > 1; i--)
+ {
+ string oldLogFilePath = $"{_logFilePath}.{i}";
+ string newLogFilePath = $"{_logFilePath}.{i - 1}";
+ if (File.Exists(oldLogFilePath))
+ {
+ try
+ {
+ File.Delete(oldLogFilePath);
+ }
+ catch (System.Exception ex)
+ {
+ _logger.LogError($"Error deleting old log file: {ex.Message}");
+ }
+ }
+ if (File.Exists(newLogFilePath))
+ {
+ try
+ {
+ File.Move(newLogFilePath, oldLogFilePath);
+ }
+ catch (System.Exception ex)
+ {
+ _logger.LogError($"Error moving log file: {ex.Message}");
+ }
+ }
+ }
+ // move current log to log.1, which gets moved if exists in the loop above
+ try
+ {
+ File.Move(_logFilePath, $"{_logFilePath}.1");
+ }
+ catch (System.Exception ex)
+ {
+ _logger.LogError($"Error moving log file: {ex.Message}");
+ }
+ _logger.LogInfo("Existing log files versioned.");
}
}
@@ -38,7 +73,7 @@ private void InitializeLogFile()
/// The severity to include, e.g. "WARN" or "DEBUG"
/// The message to log
///
- /// This will attempt to write to the log file. If it fails, it will log an error to the BepInEx logger.
+ /// /// This will attempt to write to the log file. If it fails, it will log an error to the BepInEx logger.
///
/// Nothing is returned from this method.
///
diff --git a/DiscordConnector/PluginInfo.cs b/DiscordConnector/PluginInfo.cs
index 0189999..3a79af2 100644
--- a/DiscordConnector/PluginInfo.cs
+++ b/DiscordConnector/PluginInfo.cs
@@ -16,7 +16,7 @@ internal static class PluginInfo
{
public const string PLUGIN_ID = "games.nwest.valheim.discordconnector";
public const string PLUGIN_NAME = "Valheim Discord Connector";
- public const string PLUGIN_VERSION = "2.3.2";
+ public const string PLUGIN_VERSION = "2.3.3";
public const string PLUGIN_REPO_SHORT = "github: nwesterhausen/valheim-discordconnector";
public const string PLUGIN_AUTHOR = "Nicholas Westerhausen";
public const string SHORT_PLUGIN_ID = "discordconnector";
diff --git a/Metadata/README.md b/Metadata/README.md
index a3f4a6a..e2f0d76 100644
--- a/Metadata/README.md
+++ b/Metadata/README.md
@@ -34,6 +34,12 @@ See the [current roadmap](https://github.com/nwesterhausen/valheim-discordconnec
## Abridged Changelog
+### Version 2.3.3
+
+Fixes
+
+- Can't start plugin when the old log exists in some situations
+
### Version 2.3.2
Built against the latest version of Valheim (0.219.14, the Bog Witch update).
diff --git a/Metadata/manifest.json b/Metadata/manifest.json
index d9a38a1..6b5d8be 100644
--- a/Metadata/manifest.json
+++ b/Metadata/manifest.json
@@ -1,6 +1,6 @@
{
"name": "DiscordConnector",
- "version_number": "2.3.2",
+ "version_number": "2.3.3",
"website_url": "https://discord-connector.valheim.games.nwest.one/",
"description": "Connects your Valheim server to a Discord webhook. Works for both dedicated and client-hosted servers.",
"dependencies": [
diff --git a/Metadata/thunderstore.toml b/Metadata/thunderstore.toml
index 6cc8710..cfd25e6 100644
--- a/Metadata/thunderstore.toml
+++ b/Metadata/thunderstore.toml
@@ -4,7 +4,7 @@ schemaVersion = "0.0.1"
[package]
namespace = "nwesterhausen"
name = "DiscordConnector"
-versionNumber = "2.3.2"
+versionNumber = "2.3.3"
description = "Connects your Valheim server to a Discord webhook. Works for both dedicated and client-hosted servers."
websiteUrl = "https://discord-connector.valheim.games.nwest.one/"
containsNsfwContent = false
diff --git a/README.md b/README.md
index 7d60889..ef997bb 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
[![CodeQL](https://github.com/nwesterhausen/valheim-discordconnector/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/nwesterhausen/valheim-discordconnector/actions/workflows/codeql-analysis.yml)
[![Build](https://github.com/nwesterhausen/valheim-discordconnector/actions/workflows/dotnet.yml/badge.svg)](https://github.com/nwesterhausen/valheim-discordconnector/actions/workflows/dotnet.yml)
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/nwesterhausen/valheim-discordconnector?label=Github%20Release&style=flat&labelColor=%2332393F)](https://github.com/nwesterhausen/valheim-discordconnector/releases/latest)
-[![Thunderstore.io](https://img.shields.io/badge/Thunderstore.io-2.3.2-%23375a7f?style=flat&labelColor=%2332393F)](https://valheim.thunderstore.io/package/nwesterhausen/DiscordConnector/)
+[![Thunderstore.io](https://img.shields.io/badge/Thunderstore.io-2.3.3-%23375a7f?style=flat&labelColor=%2332393F)](https://valheim.thunderstore.io/package/nwesterhausen/DiscordConnector/)
[![NexusMods](https://img.shields.io/badge/NexusMods-2.1.14-%23D98F40?style=flat&labelColor=%2332393F)](https://www.nexusmods.com/valheim/mods/1551/)
![Built against Valheim version](https://img.shields.io/badge/Built_against_Valheim-0.219.14-purple?style=flat&labelColor=%2332393F)
diff --git a/docs/changelog.md b/docs/changelog.md
index 8837069..7e76a80 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -2,6 +2,12 @@
A full changelog of changes, dating all the way back to the first release.
+## Version 2.3.3
+
+Fixes
+
+- Can't start plugin when the old log exists in some situations
+
## Version 2.3.2
Built against the latest version of Valheim (0.219.14, the Bog Witch update).