Skip to content

Commit 1a0d13e

Browse files
committed
style: 格式化日志
1 parent 4d9efc2 commit 1a0d13e

File tree

2 files changed

+18
-62
lines changed

2 files changed

+18
-62
lines changed

framework/src/Bing.Logging/Bing/Logging/Core/LogEventContext.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class LogEventContext
1616
/// <summary>
1717
/// 标签列表
1818
/// </summary>
19-
private readonly List<string> _tags = new List<string>();
19+
private readonly List<string> _tags = new();
2020

2121
/// <summary>
2222
/// 标签列表
@@ -49,7 +49,7 @@ public LogEventContext SetTags(params string[] tags)
4949
/// <summary>
5050
/// 参数列表
5151
/// </summary>
52-
private readonly List<object> _parameters = new List<object>();
52+
private readonly List<object> _parameters = new();
5353

5454
/// <summary>
5555
/// 设置参数
@@ -86,7 +86,7 @@ public LogEventContext SetParameters(params object[] parameters)
8686
/// <summary>
8787
/// 扩展属性
8888
/// </summary>
89-
private readonly ContextData _extraProperties = new ContextData();
89+
private readonly ContextData _extraProperties = new();
9090

9191
/// <summary>
9292
/// 设置扩展属性

framework/src/Bing.Logging/Bing/Logging/Log`.cs

Lines changed: 15 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -31,93 +31,49 @@ public Log(ILogFactory factory)
3131
/// </summary>
3232
public static ILog<TCategoryName> Null = NullLog<TCategoryName>.Instance;
3333

34-
/// <summary>
35-
/// 设置日志事件标识
36-
/// </summary>
37-
/// <param name="eventId">日志事件标识</param>
34+
/// <inheritdoc />
3835
public virtual ILog EventId(EventId eventId) => _log.EventId(eventId);
3936

40-
/// <summary>
41-
/// 设置异常
42-
/// </summary>
43-
/// <param name="exception">异常</param>
37+
/// <inheritdoc />
4438
public virtual ILog Exception(Exception exception) => _log.Exception(exception);
4539

46-
/// <summary>
47-
/// 设置自定义扩展属性
48-
/// </summary>
49-
/// <param name="propertyName">属性名</param>
50-
/// <param name="propertyValue">属性值</param>
40+
/// <inheritdoc />
5141
public virtual ILog Property(string propertyName, string propertyValue) => _log.Property(propertyName, propertyValue);
5242

53-
/// <summary>
54-
/// 设置扩展属性
55-
/// </summary>
56-
/// <param name="propertyName">属性名</param>
57-
/// <param name="propertyValue">属性值</param>
43+
/// <inheritdoc />
5844
public virtual ILog ExtraProperty(string propertyName, object propertyValue) => _log.ExtraProperty(propertyName, propertyValue);
5945

60-
/// <summary>
61-
/// 设置标签
62-
/// </summary>
63-
/// <param name="tags">标签</param>
46+
/// <inheritdoc />
6447
public virtual ILog Tags(params string[] tags) => _log.Tags(tags);
6548

66-
/// <summary>
67-
/// 设置日志状态对象
68-
/// </summary>
69-
/// <param name="state">状态对象</param>
49+
/// <inheritdoc />
7050
public virtual ILog State(object state) => _log.State(state);
7151

72-
/// <summary>
73-
/// 设置日志消息
74-
/// </summary>
75-
/// <param name="message">日志消息</param>
76-
/// <param name="args">日志消息参数</param>
52+
/// <inheritdoc />
7753
public virtual ILog Message(string message, params object[] args) => _log.Message(message, args);
7854

79-
/// <summary>
80-
/// 是否启用
81-
/// </summary>
82-
/// <param name="logLevel">日志级别</param>
83-
/// <returns>true=启用;false=禁用</returns>
55+
/// <inheritdoc />
8456
public virtual bool IsEnabled(LogLevel logLevel) => _log.IsEnabled(logLevel);
8557

86-
/// <summary>
87-
/// 开启日志范围
88-
/// </summary>
89-
/// <typeparam name="TState">日志状态类型</typeparam>
90-
/// <param name="state">日志状态</param>
58+
/// <inheritdoc />
9159
public virtual IDisposable BeginScope<TState>(TState state) => _log.BeginScope(state);
9260

93-
/// <summary>
94-
/// 写跟踪日志
95-
/// </summary>
61+
/// <inheritdoc />
9662
public virtual ILog LogTrace([CallerMemberName] string memberName = "", [CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0) => _log.LogTrace();
9763

98-
/// <summary>
99-
/// 写调试日志
100-
/// </summary>
64+
/// <inheritdoc />
10165
public virtual ILog LogDebug([CallerMemberName] string memberName = "", [CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0) => _log.LogDebug();
10266

103-
/// <summary>
104-
/// 写信息日志
105-
/// </summary>
67+
/// <inheritdoc />
10668
public virtual ILog LogInformation([CallerMemberName] string memberName = "", [CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0) => _log.LogInformation();
10769

108-
/// <summary>
109-
/// 写警告日志
110-
/// </summary>
70+
/// <inheritdoc />
11171
public virtual ILog LogWarning([CallerMemberName] string memberName = "", [CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0) => _log.LogWarning();
11272

113-
/// <summary>
114-
/// 写错误日志
115-
/// </summary>
73+
/// <inheritdoc />
11674
public virtual ILog LogError([CallerMemberName] string memberName = "", [CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0) => _log.LogError();
11775

118-
/// <summary>
119-
/// 写致命日志
120-
/// </summary>
76+
/// <inheritdoc />
12177
public virtual ILog LogCritical([CallerMemberName] string memberName = "", [CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0) => _log.LogCritical();
12278
}
12379
}

0 commit comments

Comments
 (0)