This repository was archived by the owner on Mar 7, 2026. It is now read-only.
forked from btcpayserver/btcpayserver-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlashPluginLogger.cs
More file actions
79 lines (71 loc) · 2.74 KB
/
FlashPluginLogger.cs
File metadata and controls
79 lines (71 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System;
using System.IO;
using System.Reflection;
using System.Text;
namespace BTCPayServer.Plugins.Flash
{
// This class attempts to write directly to the file system
// to diagnose issues when standard logging doesn't appear
public static class FlashPluginLogger
{
private static readonly string LogFilePath = "/tmp/flash-plugin.log";
static FlashPluginLogger()
{
try
{
var logMessage = new StringBuilder();
logMessage.AppendLine("=============== FLASH PLUGIN DIAGNOSTIC LOG ===============");
logMessage.AppendLine($"Timestamp: {DateTime.UtcNow:yyyy-MM-dd HH:mm:ss.fff}");
// Assembly info
var assembly = typeof(FlashPluginLogger).Assembly;
logMessage.AppendLine($"Assembly: {assembly.FullName}");
logMessage.AppendLine($"Location: {assembly.Location}");
// Check for manifest
logMessage.AppendLine("Checking for manifest resources:");
var resources = assembly.GetManifestResourceNames();
foreach (var resource in resources)
{
logMessage.AppendLine($" - {resource}");
}
// Check for manifest.json specifically
var manifestPath = "BTCPayServer.Plugins.Flash.manifest.json";
using var stream = assembly.GetManifestResourceStream(manifestPath);
if (stream != null)
{
logMessage.AppendLine($"Found manifest at {manifestPath}");
using var reader = new StreamReader(stream);
var content = reader.ReadToEnd();
logMessage.AppendLine($"Manifest content: {content}");
}
else
{
logMessage.AppendLine($"ERROR: Manifest not found at {manifestPath}");
}
// Write to filesystem
File.WriteAllText(LogFilePath, logMessage.ToString());
}
catch (Exception ex)
{
try
{
File.WriteAllText(LogFilePath, $"ERROR in FlashPluginLogger: {ex}");
}
catch
{
// Last resort - nothing we can do if we can't write to the filesystem
}
}
}
public static void Log(string message)
{
try
{
File.AppendAllText(LogFilePath, $"[{DateTime.UtcNow:HH:mm:ss.fff}] {message}\n");
}
catch
{
// Ignore failures to avoid crashing the plugin
}
}
}
}