2017-07-20 14:16:47 +02:00
|
|
|
|
/*
|
2024-03-05 18:37:42 +01:00
|
|
|
|
* Copyright (c) 2024 ETH Zürich, IT Services
|
2017-07-20 14:16:47 +02:00
|
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2019-08-30 09:55:26 +02:00
|
|
|
|
using SafeExamBrowser.Logging.Contracts;
|
2019-09-06 09:39:28 +02:00
|
|
|
|
using SafeExamBrowser.Settings.Logging;
|
2017-07-20 14:16:47 +02:00
|
|
|
|
|
2018-08-31 10:06:27 +02:00
|
|
|
|
namespace SafeExamBrowser.Logging
|
2017-07-20 14:16:47 +02:00
|
|
|
|
{
|
2018-08-31 15:29:36 +02:00
|
|
|
|
public class ModuleLogger : IModuleLogger
|
2017-07-20 14:16:47 +02:00
|
|
|
|
{
|
|
|
|
|
private ILogger logger;
|
2018-08-31 07:49:41 +02:00
|
|
|
|
private string moduleInfo;
|
2017-07-20 14:16:47 +02:00
|
|
|
|
|
2019-01-23 08:12:15 +01:00
|
|
|
|
public LogLevel LogLevel
|
|
|
|
|
{
|
|
|
|
|
get { return logger.LogLevel; }
|
|
|
|
|
set { logger.LogLevel = value; }
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-31 07:49:41 +02:00
|
|
|
|
public ModuleLogger(ILogger logger, string moduleInfo)
|
2017-07-20 14:16:47 +02:00
|
|
|
|
{
|
|
|
|
|
this.logger = logger;
|
2018-08-31 07:49:41 +02:00
|
|
|
|
this.moduleInfo = moduleInfo;
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-31 15:29:36 +02:00
|
|
|
|
public IModuleLogger CloneFor(string moduleInfo)
|
2018-08-31 07:49:41 +02:00
|
|
|
|
{
|
2018-08-31 15:29:36 +02:00
|
|
|
|
return new ModuleLogger(logger, moduleInfo);
|
2017-07-20 14:16:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-23 15:33:54 +01:00
|
|
|
|
public void Debug(string message)
|
|
|
|
|
{
|
|
|
|
|
logger.Debug(AppendModuleInfo(message));
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-20 14:16:47 +02:00
|
|
|
|
public void Error(string message)
|
|
|
|
|
{
|
|
|
|
|
logger.Error(AppendModuleInfo(message));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Error(string message, Exception exception)
|
|
|
|
|
{
|
|
|
|
|
logger.Error(AppendModuleInfo(message), exception);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IList<ILogContent> GetLog()
|
|
|
|
|
{
|
|
|
|
|
return logger.GetLog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Info(string message)
|
|
|
|
|
{
|
|
|
|
|
logger.Info(AppendModuleInfo(message));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Log(string message)
|
|
|
|
|
{
|
|
|
|
|
logger.Log(message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Subscribe(ILogObserver observer)
|
|
|
|
|
{
|
|
|
|
|
logger.Subscribe(observer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Unsubscribe(ILogObserver observer)
|
|
|
|
|
{
|
|
|
|
|
logger.Unsubscribe(observer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Warn(string message)
|
|
|
|
|
{
|
|
|
|
|
logger.Warn(AppendModuleInfo(message));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string AppendModuleInfo(string message)
|
|
|
|
|
{
|
2018-08-31 07:49:41 +02:00
|
|
|
|
return $"[{moduleInfo}] {message}";
|
2017-07-20 14:16:47 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|