Restore SEBPatch
This commit is contained in:
19
SafeExamBrowser.Logging.Contracts/ILogContent.cs
Normal file
19
SafeExamBrowser.Logging.Contracts/ILogContent.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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;
|
||||
|
||||
namespace SafeExamBrowser.Logging.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a content element of the application log.
|
||||
/// </summary>
|
||||
public interface ILogContent : ICloneable
|
||||
{
|
||||
}
|
||||
}
|
21
SafeExamBrowser.Logging.Contracts/ILogContentFormatter.cs
Normal file
21
SafeExamBrowser.Logging.Contracts/ILogContentFormatter.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.Logging.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a formatter to be used to unify the look of and information rendered in an application log.
|
||||
/// </summary>
|
||||
public interface ILogContentFormatter
|
||||
{
|
||||
/// <summary>
|
||||
/// Formats the given log content and returns it as a <c>string</c>.
|
||||
/// </summary>
|
||||
string Format(ILogContent content);
|
||||
}
|
||||
}
|
39
SafeExamBrowser.Logging.Contracts/ILogMessage.cs
Normal file
39
SafeExamBrowser.Logging.Contracts/ILogMessage.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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 SafeExamBrowser.Settings.Logging;
|
||||
|
||||
namespace SafeExamBrowser.Logging.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a typical (i.e. prioritized and timestamped) log message as content element of the application log.
|
||||
/// </summary>
|
||||
public interface ILogMessage : ILogContent
|
||||
{
|
||||
/// <summary>
|
||||
/// The date when the message was logged.
|
||||
/// </summary>
|
||||
DateTime DateTime { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The severity of the message.
|
||||
/// </summary>
|
||||
LogLevel Severity { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The message itself.
|
||||
/// </summary>
|
||||
string Message { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Information about the thread on which the message was logged.
|
||||
/// </summary>
|
||||
IThreadInfo ThreadInfo { get; }
|
||||
}
|
||||
}
|
21
SafeExamBrowser.Logging.Contracts/ILogObserver.cs
Normal file
21
SafeExamBrowser.Logging.Contracts/ILogObserver.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.Logging.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines an observer of the application log which can subscribe to a logger via <see cref="ILogger.Subscribe(ILogObserver)"/>.
|
||||
/// </summary>
|
||||
public interface ILogObserver
|
||||
{
|
||||
/// <summary>
|
||||
/// Notifies an observer once new content has been added to the application log.
|
||||
/// </summary>
|
||||
void Notify(ILogContent content);
|
||||
}
|
||||
}
|
21
SafeExamBrowser.Logging.Contracts/ILogText.cs
Normal file
21
SafeExamBrowser.Logging.Contracts/ILogText.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.Logging.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines raw text data as content element of the application log.
|
||||
/// </summary>
|
||||
public interface ILogText : ILogContent
|
||||
{
|
||||
/// <summary>
|
||||
/// The raw text to be appended to the application log.
|
||||
/// </summary>
|
||||
string Text { get; }
|
||||
}
|
||||
}
|
78
SafeExamBrowser.Logging.Contracts/ILogger.cs
Normal file
78
SafeExamBrowser.Logging.Contracts/ILogger.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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;
|
||||
using SafeExamBrowser.Settings.Logging;
|
||||
|
||||
namespace SafeExamBrowser.Logging.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the functionality of the logger.
|
||||
/// </summary>
|
||||
public interface ILogger
|
||||
{
|
||||
/// <summary>
|
||||
/// The currently active severity threshold. All messages with a lower severity won't be logged!
|
||||
/// </summary>
|
||||
LogLevel LogLevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Logs the given message with severity <see cref="LogLevel.Debug"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="ArgumentNullException" />
|
||||
void Debug(string message);
|
||||
|
||||
/// <summary>
|
||||
/// Logs the given message with severity <see cref="LogLevel.Info"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="ArgumentNullException" />
|
||||
void Info(string message);
|
||||
|
||||
/// <summary>
|
||||
/// Logs the given message with severity <see cref="LogLevel.Warning"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="ArgumentNullException" />
|
||||
void Warn(string message);
|
||||
|
||||
/// <summary>
|
||||
/// Logs the given message with severity <see cref="LogLevel.Error"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="ArgumentNullException" />
|
||||
void Error(string message);
|
||||
|
||||
/// <summary>
|
||||
/// Logs the given message with severity <see cref="LogLevel.Error"/> and includes
|
||||
/// information about the specified exception (i.e. type, message and stacktrace).
|
||||
/// </summary>
|
||||
/// <exception cref="ArgumentNullException" />
|
||||
void Error(string message, Exception exception);
|
||||
|
||||
/// <summary>
|
||||
/// Logs the given message as raw text.
|
||||
/// </summary>
|
||||
/// <exception cref="ArgumentNullException" />
|
||||
void Log(string message);
|
||||
|
||||
/// <summary>
|
||||
/// Subscribes an observer to the application log.
|
||||
/// </summary>
|
||||
/// <exception cref="ArgumentNullException" />
|
||||
void Subscribe(ILogObserver observer);
|
||||
|
||||
/// <summary>
|
||||
/// Unsubscribes an observer from the application log.
|
||||
/// </summary>
|
||||
void Unsubscribe(ILogObserver observer);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a copy of the current log content.
|
||||
/// </summary>
|
||||
IList<ILogContent> GetLog();
|
||||
}
|
||||
}
|
21
SafeExamBrowser.Logging.Contracts/IModuleLogger.cs
Normal file
21
SafeExamBrowser.Logging.Contracts/IModuleLogger.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.Logging.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// An implementation of <see cref="ILogger"/> which automatically appends information about the module from which messages are logged.
|
||||
/// </summary>
|
||||
public interface IModuleLogger : ILogger
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance which will automatically append the given module information.
|
||||
/// </summary>
|
||||
IModuleLogger CloneFor(string moduleInfo);
|
||||
}
|
||||
}
|
33
SafeExamBrowser.Logging.Contracts/IThreadInfo.cs
Normal file
33
SafeExamBrowser.Logging.Contracts/IThreadInfo.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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;
|
||||
|
||||
namespace SafeExamBrowser.Logging.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines information about a thread, to be associated with an <see cref="ILogMessage"/>.
|
||||
/// </summary>
|
||||
public interface IThreadInfo : ICloneable
|
||||
{
|
||||
/// <summary>
|
||||
/// The id of the thread.
|
||||
/// </summary>
|
||||
int Id { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The thread's name.
|
||||
/// </summary>
|
||||
string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A flag indicating whether the thread has a name.
|
||||
/// </summary>
|
||||
bool HasName { get; }
|
||||
}
|
||||
}
|
33
SafeExamBrowser.Logging.Contracts/Properties/AssemblyInfo.cs
Normal file
33
SafeExamBrowser.Logging.Contracts/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("SafeExamBrowser.Logging.Contracts")]
|
||||
[assembly: AssemblyDescription("Safe Exam Browser")]
|
||||
[assembly: AssemblyCompany("ETH Zürich")]
|
||||
[assembly: AssemblyProduct("SafeExamBrowser.Logging.Contracts")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2024 ETH Zürich, IT Services")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("64ea30fb-11d4-436a-9c2b-88566285363e")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: AssemblyInformationalVersion("1.0.0.0")]
|
@@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{64EA30FB-11D4-436A-9C2B-88566285363E}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>SafeExamBrowser.Logging.Contracts</RootNamespace>
|
||||
<AssemblyName>SafeExamBrowser.Logging.Contracts</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ILogContent.cs" />
|
||||
<Compile Include="ILogContentFormatter.cs" />
|
||||
<Compile Include="ILogger.cs" />
|
||||
<Compile Include="ILogMessage.cs" />
|
||||
<Compile Include="ILogObserver.cs" />
|
||||
<Compile Include="ILogText.cs" />
|
||||
<Compile Include="IModuleLogger.cs" />
|
||||
<Compile Include="IThreadInfo.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SafeExamBrowser.Settings\SafeExamBrowser.Settings.csproj">
|
||||
<Project>{30b2d907-5861-4f39-abad-c4abf1b3470e}</Project>
|
||||
<Name>SafeExamBrowser.Settings</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
Reference in New Issue
Block a user