-
Notifications
You must be signed in to change notification settings - Fork 19
/
IdentityLogger.cs
46 lines (41 loc) · 1.45 KB
/
IdentityLogger.cs
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using Microsoft.IdentityModel.Abstractions;
using System.Diagnostics;
namespace SignInMaui.MSALClient
{
/// <summary>
/// An example of how to use MSAL.NET logging
/// </summary>
/// <seealso cref="IIdentityLogger" />
/// <autogeneratedoc />
public class IdentityLogger : IIdentityLogger
{
private EventLogLevel _minLogLevel = EventLogLevel.LogAlways;
/// <summary>
/// Create instance of IIdentityLogger implementer and set a logging level for this instance
/// </summary>
/// <param name="minLogLevel">Default: LogAlways</param>
public IdentityLogger(EventLogLevel minLogLevel = EventLogLevel.LogAlways)
{
_minLogLevel = minLogLevel;
}
/// <summary>
/// Checks if log is enabled or not based on the Entry level
/// </summary>
/// <param name="eventLogLevel"></param>
/// <returns></returns>
public bool IsEnabled(EventLogLevel eventLogLevel)
{
return eventLogLevel >= _minLogLevel;
}
/// <summary>
/// Log to console for demo purpose
/// </summary>
/// <param name="entry">Log Entry values</param>
public void Log(LogEntry entry)
{
Debug.WriteLine($"MSAL: EventLogLevel: {entry.EventLogLevel}, Message: {entry.Message} ");
}
}
}