Skip to content

Commit

Permalink
Add Config for Timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
NepuShiro committed Oct 17, 2023
1 parent 159a7c2 commit 97d65a3
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 13 deletions.
43 changes: 36 additions & 7 deletions Plugin.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
using BepInEx;
using BepInEx.Configuration;
using UnityEngine;
using System;
using System.Text.RegularExpressions;
using BCE;
using Elements.Core;
using static OfficialAssets.Graphics;
using static UnityEngine.UIElements.StyleVariableResolver;

namespace RedirectLog
{
[BepInPlugin("org.nep.RedirectLog", "RedirectLog", "1.0.0")]
[BepInPlugin("org.Nep.RedirectLog", "RedirectLog", "1.0.1")]
public class RedirectLog : BaseUnityPlugin
{

private ConfigEntry<bool> configEnableTimestamp;
private ConfigEntry<bool> configEnableFPS;
void Awake()
{
configEnableTimestamp = Config.Bind("General",
"Enable TimeStamps",
true,
"Whether or not to show TimeStamps in the Log");
configEnableFPS = Config.Bind("General",
"Enable FPS Log",
false,
"Whether or not to show the FPS in the Log");
UniLog.OnLog += OnLogMessage;
UniLog.OnWarning += OnWarningMessage;
UniLog.OnError += OnErrorMessage;
Expand Down Expand Up @@ -99,14 +111,31 @@ void FormatModLoaderLog(string message)

string RemoveTimestampAndFPS(string message)
{
string pattern1 = @"\d{1,2}:\d{1,2}:\d{1,2} [APap][Mm]\.\d{1,3} \(\s*-*\d+\s?FPS\s?\)\s+";
string pattern1 = @"\d{1,2}:\d{1,2}:\d{1,2} [APap][Mm]\.\d{1,3}\s";
string pattern2 = @"\(\s*-*\d+\s?FPS\s?\)\s+";

string pattern2 = @"\d{1,2}:\d{1,2}:\d{1,2} [APap][Mm]\.\d{1,3} \(\s*-*\d+\s?FPS\s?\)\s+";
if (!configEnableTimestamp.Value)
{
string result = Regex.Replace(message, pattern1, "");

string result = Regex.Replace(message, pattern1, "");
result = Regex.Replace(result, pattern2, "");
if (!configEnableFPS.Value)
{
string result2 = Regex.Replace(result, pattern2, "");

return result;
return result2;
}
else return result;
}
else
{
if (!configEnableFPS.Value)
{
string result2 = Regex.Replace(message, pattern2, "");

return result2;
}
else return message;
}
}

bool IsValidLog(string message)
Expand Down
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,28 @@
### Installation
Download and extract [BepInEx 5.4.22 x64](https://github.com/BepInEx/BepInEx/releases) into the main game folder and run the game once to generate the folders and config files

You will also need to download [BCE](https://github.com/innominata/BepInEx-Console-Extensions/releases/tag/1.0) (BepInEx Console Extensions) and place this into the "GameDir"/BepInEx/Plugins
You will also need to download [BCE](https://github.com/innominata/BepInEx-Console-Extensions/releases/tag/1.0) (BepInEx Console Extensions) and place this into the "GameDir"/BepInEx/plugins

Finally download the RedirectLog.dll from the [Releases](https://github.com/nepushiro/RedirectLog/releases) and place this into the "GameDir"/BepInEx/Plugins
Finally download the RedirectLog.dll from the [Releases](https://github.com/nepushiro/RedirectLog/releases) and place this into the "GameDir"/BepInEx/plugins

To get the Console to appear it is disabled by default in the BepInEx config ("GameDir"/BepInEx/Config)
To get the Console to appear it is disabled by default in the BepInEx config ("GameDir"/BepInEx/config)

Now your Console should be displaying the logs!
Now your Console should be displaying the logs!

#### For Enabling TimeStamps and/or FPS

This will be in the Config in "GameDir"/BepInEx/config/org.Nep.RedirectLog.cfg

```
[General]
## Whether or not to show TimeStamps in the Log
# Setting type: Boolean
# Default value: true
Enable TimeStamps = true
## Whether or not to show the FPS in the Log
# Setting type: Boolean
# Default value: false
Enable FPS Log = false
```
4 changes: 2 additions & 2 deletions RedirectLog.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<AssemblyName>RedirectLog</AssemblyName>
<Description>My first plugin</Description>
<Version>1.0.0</Version>
<Description>Redirect the Logs for Resonite to BepInEx</Description>
<Version>1.0.1</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
</PropertyGroup>
Expand Down

0 comments on commit 97d65a3

Please sign in to comment.