-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLogOptions.cs
More file actions
77 lines (76 loc) · 2.46 KB
/
LogOptions.cs
File metadata and controls
77 lines (76 loc) · 2.46 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* ===============================================
* 功能描述:AspNetCore.FileLog.LogOptions
* 创 建 者:WeiGe
* 创建日期:1/16/2019 12:18:31 AM
* ===============================================*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
namespace AspNetCore.FileLog
{
/// <summary>
/// log options
/// </summary>
public class LogOptions
{
/// <summary>
/// request url
/// <para>
/// default: "/_Logs_"
/// </para>
/// </summary>
public string LogRequestPath { get; set; } = "/_Logs_";
/// <summary>
/// settings url
/// <para>
/// default: "/_Settings_"
/// </para>
/// </summary>
public string SettingsPath { get; set; } = "/_Settings_";
/// <summary>
/// Log file physical directory
/// <para>
/// default: ".Logs" of application path
/// </para>
/// </summary>
public string LogDirectory { get; set; }
/// <summary>
///
/// </summary>
internal ICollection<ServiceDescriptor> LogAdapters { get; } = new List<ServiceDescriptor>();
/// <summary>
/// use text log adapter
/// </summary>
public void UseText()
{
if (!LogAdapters.Any(x => x.ImplementationType == typeof(TextLogAdapter) || x.ImplementationInstance is TextLogAdapter))
{
LogAdapters.Add(ServiceDescriptor.Singleton<LogAdapter, TextLogAdapter>());
}
}
/// <summary>
/// use markdown log adapter
/// </summary>
public void UseMarkdown()
{
if (!LogAdapters.Any(x => x.ImplementationType ==typeof( MarkdownLogAdapter)||x.ImplementationInstance is MarkdownLogAdapter))
{
LogAdapters.Add(ServiceDescriptor.Singleton<LogAdapter, MarkdownLogAdapter>());
}
}
/// <summary>
/// use log adapter
/// </summary>
/// <typeparam name="TAdapter"></typeparam>
public void UseLogAdapter<TAdapter>()
where TAdapter : LogAdapter
{
if (!LogAdapters.Any(x => x.ImplementationType == typeof(TAdapter) || x.ImplementationInstance is TAdapter))
{
LogAdapters.Add(ServiceDescriptor.Singleton<LogAdapter, TAdapter>());
}
}
}
}