-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathLog.cs
More file actions
57 lines (43 loc) · 1.36 KB
/
Log.cs
File metadata and controls
57 lines (43 loc) · 1.36 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
using System;
using System.Windows;
namespace FFBitrateViewer
{
public static class Log
{
private static Logger? Logger = null;
public static bool IsLogCommands = false;
public static void Init(Logger logger, bool isLogCommands = false)
{
Logger = logger;
IsLogCommands = isLogCommands;
}
public static void Close()
{
Logger?.Close();
}
public static bool LogLevelIs(LogLevel logLevel)
{
return Logger?.MinLevel == logLevel;
}
public static void Write(LogLevel logLevel, string line)
{
try
{
Logger?.Log(logLevel, line);
}
catch (Exception)
{
MessageBox.Show("FFBitrateViewer unable to write into file:\n" + Logger?.FileName + "\n\nLogging is disabled.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
Logger?.Disable();
}
}
public static void Write(LogLevel logLevel, params string[] values)
{
Write(logLevel, string.Join(", ", values));
}
public static void WriteCommand(string executable, string? args)
{
if(IsLogCommands) Write(LogLevel.INFO, executable + " " + args);
}
}
}