Skip to content

Commit

Permalink
feat: add more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaslagoni committed Jan 29, 2023
1 parent fd126a2 commit 009aa4d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Oxide.Ext.GamingApi/GamingApiNats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using NATS.Client.JetStream;
using System.Configuration;
using System.IO;
using System.Text;

namespace Oxide.Ext.GamingApi
{
Expand Down Expand Up @@ -84,7 +85,7 @@ private GamingApiNats(LoggingInterface logger)
{
// get a private key seed from your environment.
string seed = this.GetNatsJwtSeed();
this.Logger.Info("NATS: Loading jwt seed : " + seed.Substring(0, 3));
this.Logger.Info("NATS: Loading jwt seed : " + seed.Substring(0, 3) + "....");

// Generate a NkeyPair
NkeyPair kp = Nkeys.FromSeed(seed);
Expand Down Expand Up @@ -176,7 +177,16 @@ private string GetNatsNkeySeed()
}
return value;
}

public string PrintByteArray(byte[] bytes)
{
var sb = new StringBuilder("new byte[] { ");
foreach (var b in bytes)
{
sb.Append(b + ", ");
}
sb.Append("}");
return sb.ToString();
}
private string GetNatsJwtUser()
{

Expand All @@ -188,6 +198,7 @@ private string GetNatsJwtUser()
{
this.Logger.Info($"NATS: {envFileName} loading from file");
string contents = File.ReadAllText(@fileName);
this.Logger.Info($"NATS: {envFileName} length was - {PrintByteArray(Encoding.UTF8.GetBytes(contents))}");
return contents;
}

Expand All @@ -211,6 +222,7 @@ private string GetNatsJwtSeed()
{
this.Logger.Info($"NATS: {envFileName} loading from file");
string contents = File.ReadAllText(@fileName);
this.Logger.Info($"NATS: {envFileName} length was - {PrintByteArray(Encoding.UTF8.GetBytes(contents))}");
return contents;
}
var value = Environment.GetEnvironmentVariable(envName);
Expand Down

0 comments on commit 009aa4d

Please sign in to comment.