blob: bb0ae31cddc67eeea62dd218fe8953d5bb7778df (
plain)
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
|
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="LogManager.cs" company="HandBrake Project (http://handbrake.fr)">
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
// </copyright>
// <summary>
// The log manager.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrakeWPF.Helpers
{
using System.IO;
using Caliburn.Micro;
using HandBrake.Interop.Interop;
using HandBrake.Interop.Interop.Interfaces.EventArgs;
using HandBrakeWPF.Services.Logging.Interfaces;
using HandBrakeWPF.Utilities;
using ILog = Services.Logging.Interfaces.ILog;
public static class LogManager
{
private static ILog generalAppLogger;
public static void Init()
{
generalAppLogger = IoC.Get<ILog>();
string logDir = DirectoryUtilities.GetLogDirectory();
string filename = string.Format("activity_log_main.{0}.txt", GeneralUtilities.ProcessId);
string logFile = Path.Combine(logDir, filename);
generalAppLogger.ConfigureLogging(filename, logFile);
IoC.Get<ILogInstanceManager>().Register(filename, generalAppLogger, true);
HandBrakeUtils.MessageLogged += HandBrakeUtils_MessageLogged;
HandBrakeUtils.ErrorLogged += HandBrakeUtils_ErrorLogged;
}
private static void HandBrakeUtils_ErrorLogged(object sender, MessageLoggedEventArgs e)
{
if (e == null || string.IsNullOrEmpty(e.Message))
{
return;
}
generalAppLogger?.LogMessage(e.Message);
}
private static void HandBrakeUtils_MessageLogged(object sender, MessageLoggedEventArgs e)
{
if (e == null || string.IsNullOrEmpty(e.Message))
{
return;
}
generalAppLogger?.LogMessage(e.Message);
}
}
}
|