-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathActivityMonitorSimpleSenderExtension.Group.cs
More file actions
232 lines (218 loc) · 14.8 KB
/
ActivityMonitorSimpleSenderExtension.Group.cs
File metadata and controls
232 lines (218 loc) · 14.8 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
using System;
using System.Runtime.CompilerServices;
namespace CK.Core;
public static partial class ActivityMonitorSimpleSenderExtension
{
/// <summary>
/// Opens a given <see cref="LogLevel"/> group with an exception.
/// Regardless of whether it will be emitted or not (this depends on <see cref="IActivityMonitor.ActualFilter"/>,
/// the global default <see cref="ActivityMonitor.DefaultFilter"/> and may also depend on <see cref="IActivityMonitor.AutoTags"/>),
/// it must always be closed.
/// </summary>
/// <param name="monitor">This <see cref="IActivityMonitor"/>.</param>
/// <param name="level">The log level.</param>
/// <param name="ex">The exception to log.</param>
/// <param name="lineNumber">Line number in the source file (automatically injected by C# compiler).</param>
/// <param name="fileName">Source file name of the emitter (automatically injected by C# compiler).</param>
/// <returns>A disposable object that can be used to set a function that provides a conclusion text and/or close the group.</returns>
[MethodImpl( MethodImplOptions.AggressiveInlining )]
public static IDisposableGroup OpenGroup( this IActivityMonitor monitor,
LogLevel level,
Exception ex,
[CallerLineNumber] int lineNumber = 0,
[CallerFilePath] string? fileName = null )
{
var d = monitor.ShouldLogGroup( level, null, out var finalTags )
? monitor.CreateActivityMonitorLogData( level | LogLevel.IsFiltered, finalTags, null, ex, fileName, lineNumber, true )
: default;
return monitor.UnfilteredOpenGroup( ref d );
}
/// <summary>
/// Opens a given <see cref="LogLevel"/> group with a text message.
/// Regardless of whether it will be emitted or not (this depends on <see cref="IActivityMonitor.ActualFilter"/>,
/// the global default <see cref="ActivityMonitor.DefaultFilter"/> and may also depend on <see cref="IActivityMonitor.AutoTags"/>),
/// it must always be closed.
/// </summary>
/// <param name="monitor">This <see cref="IActivityMonitor"/>.</param>
/// <param name="level">The log level.</param>
/// <param name="text">The text to log.</param>
/// <param name="lineNumber">Line number in the source file (automatically injected by C# compiler).</param>
/// <param name="fileName">Source file name of the emitter (automatically injected by C# compiler).</param>
/// <returns>A disposable object that can be used to set a function that provides a conclusion text and/or close the group.</returns>
[MethodImpl( MethodImplOptions.AggressiveInlining )]
public static IDisposableGroup OpenGroup( this IActivityMonitor monitor,
LogLevel level,
string text,
[CallerLineNumber] int lineNumber = 0,
[CallerFilePath] string? fileName = null )
{
var d = monitor.ShouldLogGroup( level, null, out var finalTags )
? monitor.CreateActivityMonitorLogData( level | LogLevel.IsFiltered, finalTags, text, null, fileName, lineNumber, true )
: default;
return monitor.UnfilteredOpenGroup( ref d );
}
/// <inheritdoc cref="OpenGroup(IActivityMonitor, LogLevel, string, int, string?)"/>
public static IDisposableGroup OpenGroup( this IActivityMonitor monitor,
LogLevel level,
[InterpolatedStringHandlerArgument( "monitor", "level" )] LogHandler.GroupLog text,
[CallerLineNumber] int lineNumber = 0,
[CallerFilePath] string? fileName = null )
{
var t = text._handler.ToStringAndClear();
var d = t != null
? monitor.CreateActivityMonitorLogData( level | LogLevel.IsFiltered, text._handler.FinalTags, t, null, fileName, lineNumber, true )
: default;
return monitor.UnfilteredOpenGroup( ref d );
}
/// <summary>
/// Opens a given <see cref="LogLevel"/> group with a text message associated to an exception.
/// Regardless of whether it will be emitted or not (this depends on <see cref="IActivityMonitor.ActualFilter"/>,
/// the global default <see cref="ActivityMonitor.DefaultFilter"/> and may also depend on <see cref="IActivityMonitor.AutoTags"/>),
/// it must always be closed.
/// </summary>
/// <param name="monitor">This <see cref="IActivityMonitor"/>.</param>
/// <param name="level">The log level.</param>
/// <param name="text">The text to log.</param>
/// <param name="ex">The exception to log.</param>
/// <param name="lineNumber">Line number in the source file (automatically injected by C# compiler).</param>
/// <param name="fileName">Source file name of the emitter (automatically injected by C# compiler).</param>
/// <returns>A disposable object that can be used to set a function that provides a conclusion text and/or close the group.</returns>
[MethodImpl( MethodImplOptions.AggressiveInlining )]
public static IDisposableGroup OpenGroup( this IActivityMonitor monitor,
LogLevel level,
string? text,
Exception? ex,
[CallerLineNumber] int lineNumber = 0,
[CallerFilePath] string? fileName = null )
{
var d = monitor.ShouldLogGroup( level, null, out var finalTags )
? monitor.CreateActivityMonitorLogData( level | LogLevel.IsFiltered, finalTags, text, ex, fileName, lineNumber, true )
: default;
return monitor.UnfilteredOpenGroup( ref d );
}
/// <inheritdoc cref="OpenGroup(IActivityMonitor, LogLevel, string, Exception?, int, string?)"/>
public static IDisposableGroup OpenGroup( this IActivityMonitor monitor,
LogLevel level,
[InterpolatedStringHandlerArgument( "monitor", "level" )] LogHandler.GroupLog text,
Exception? ex,
[CallerLineNumber] int lineNumber = 0,
[CallerFilePath] string? fileName = null )
{
var t = text._handler.ToStringAndClear();
var d = t != null
? monitor.CreateActivityMonitorLogData( level | LogLevel.IsFiltered, text._handler.FinalTags, t, ex, fileName, lineNumber, true )
: default;
return monitor.UnfilteredOpenGroup( ref d );
}
#region Debug with tags.
/// <summary>
/// Opens a given <see cref="LogLevel"/> group with an exception and tags.
/// Regardless of whether it will be emitted or not (this depends on <see cref="IActivityMonitor.ActualFilter"/>,
/// the global default <see cref="ActivityMonitor.DefaultFilter"/> and may also depend on <paramref name="tags"/> and
/// <see cref="IActivityMonitor.AutoTags"/>), it must always be closed.
/// </summary>
/// <param name="monitor">This <see cref="IActivityMonitor"/>.</param>
/// <param name="level">The log level.</param>
/// <param name="tags">Optional tags for this log.</param>
/// <param name="ex">The exception to log.</param>
/// <param name="lineNumber">Line number in the source file (automatically injected by C# compiler).</param>
/// <param name="fileName">Source file name of the emitter (automatically injected by C# compiler).</param>
/// <returns>A disposable object that can be used to set a function that provides a conclusion text and/or close the group.</returns>
[MethodImpl( MethodImplOptions.AggressiveInlining )]
public static IDisposableGroup OpenGroup( this IActivityMonitor monitor,
LogLevel level,
CKTrait? tags,
Exception ex,
[CallerLineNumber] int lineNumber = 0,
[CallerFilePath] string? fileName = null )
{
var d = monitor.ShouldLogGroup( level, tags, out var finalTags )
? monitor.CreateActivityMonitorLogData( level | LogLevel.IsFiltered, finalTags, null, ex, fileName, lineNumber, true )
: default;
return monitor.UnfilteredOpenGroup( ref d );
}
/// <summary>
/// Opens a given <see cref="LogLevel"/> group with a text message and tags.
/// Regardless of whether it will be emitted or not (this depends on <see cref="IActivityMonitor.ActualFilter"/>,
/// the global default <see cref="ActivityMonitor.DefaultFilter"/> and may also depend on <paramref name="tags"/> and
/// <see cref="IActivityMonitor.AutoTags"/>), it must always be closed.
/// </summary>
/// <param name="monitor">This <see cref="IActivityMonitor"/>.</param>
/// <param name="level">The log level.</param>
/// <param name="tags">Optional tags for this log.</param>
/// <param name="text">The text to log.</param>
/// <param name="lineNumber">Line number in the source file (automatically injected by C# compiler).</param>
/// <param name="fileName">Source file name of the emitter (automatically injected by C# compiler).</param>
/// <returns>A disposable object that can be used to set a function that provides a conclusion text and/or close the group.</returns>
[MethodImpl( MethodImplOptions.AggressiveInlining )]
public static IDisposableGroup OpenGroup( this IActivityMonitor monitor,
LogLevel level,
CKTrait? tags,
string text,
[CallerLineNumber] int lineNumber = 0,
[CallerFilePath] string? fileName = null )
{
var d = monitor.ShouldLogGroup( level, tags, out var finalTags )
? monitor.CreateActivityMonitorLogData( level | LogLevel.IsFiltered, finalTags, text, null, fileName, lineNumber, true )
: default;
return monitor.UnfilteredOpenGroup( ref d );
}
/// <inheritdoc cref="OpenGroup(IActivityMonitor, LogLevel, CKTrait?, string, int, string?)"/>
public static IDisposableGroup OpenGroup( this IActivityMonitor monitor,
LogLevel level,
CKTrait? tags,
[InterpolatedStringHandlerArgument( "monitor", "level", "tags" )] LogHandler.GroupLogWithTags text,
[CallerLineNumber] int lineNumber = 0,
[CallerFilePath] string? fileName = null )
{
var t = text._handler.ToStringAndClear();
var d = t != null
? monitor.CreateActivityMonitorLogData( level | LogLevel.IsFiltered, text._handler.FinalTags, t, null, fileName, lineNumber, true )
: default;
return monitor.UnfilteredOpenGroup( ref d );
}
/// <summary>
/// Opens a given <see cref="LogLevel"/> group with a text message associated to an <see cref="Exception"/> or <see cref="CKExceptionData"/> and tags.
/// Regardless of whether it will be emitted or not (this depends on <see cref="IActivityMonitor.ActualFilter"/>,
/// the global default <see cref="ActivityMonitor.DefaultFilter"/> and may also depend on <paramref name="tags"/> and
/// <see cref="IActivityMonitor.AutoTags"/>), it must always be closed.
/// </summary>
/// <param name="monitor">This <see cref="IActivityMonitor"/>.</param>
/// <param name="level">The log level.</param>
/// <param name="tags">Optional tags for this log.</param>
/// <param name="text">The text to log.</param>
/// <param name="error">The <see cref="Exception"/> or <see cref="CKExceptionData"/> to log.</param>
/// <param name="lineNumber">Line number in the source file (automatically injected by C# compiler).</param>
/// <param name="fileName">Source file name of the emitter (automatically injected by C# compiler).</param>
/// <returns>A disposable object that can be used to set a function that provides a conclusion text and/or close the group.</returns>
[MethodImpl( MethodImplOptions.AggressiveInlining )]
public static IDisposableGroup OpenGroup( this IActivityMonitor monitor,
LogLevel level,
CKTrait? tags,
string? text,
object? error,
[CallerLineNumber] int lineNumber = 0,
[CallerFilePath] string? fileName = null )
{
var d = monitor.ShouldLogGroup( level, tags, out var finalTags )
? monitor.CreateActivityMonitorLogData( level | LogLevel.IsFiltered, finalTags, text, error, fileName, lineNumber, true )
: default;
return monitor.UnfilteredOpenGroup( ref d );
}
/// <inheritdoc cref="OpenGroup(IActivityMonitor, LogLevel, CKTrait?, Exception, int, string?)"/>
public static IDisposableGroup OpenGroup( this IActivityMonitor monitor,
LogLevel level,
CKTrait? tags,
[InterpolatedStringHandlerArgument( "monitor", "level", "tags" )] LogHandler.GroupLogWithTags text,
Exception? ex,
[CallerLineNumber] int lineNumber = 0,
[CallerFilePath] string? fileName = null )
{
var t = text._handler.ToStringAndClear();
var d = t != null
? monitor.CreateActivityMonitorLogData( level | LogLevel.IsFiltered, text._handler.FinalTags, t, ex, fileName, lineNumber, true )
: default;
return monitor.UnfilteredOpenGroup( ref d );
}
#endregion
}