3
3
using Exceptionless . Models ;
4
4
using Exceptionless . Models . Data ;
5
5
using NLog ;
6
- using NLog . Fluent ;
7
6
8
7
namespace Exceptionless . NLog {
9
- public static class LogBuilderExtensions {
8
+ public static class LogEventBuilderExtensions {
9
+ /// <summary>
10
+ /// Sets the logger name of the logging event.
11
+ /// </summary>
12
+ /// <param name="builder">The log builder object.</param>
13
+ /// <param name="loggerName">The logger name of the logging event.</param>
14
+ /// <returns>current <see cref="LogEventBuilder"/> for chaining calls.</returns>
15
+ internal static LogEventBuilder LoggerName ( this LogEventBuilder builder , string loggerName = null ) {
16
+ if ( builder . LogEvent != null )
17
+ builder . LogEvent . LoggerName = loggerName ;
18
+
19
+ return builder ;
20
+ }
21
+
10
22
/// <summary>
11
23
/// Marks the event as being a critical occurrence.
12
24
/// </summary>
13
- public static LogBuilder Critical ( this LogBuilder builder , bool isCritical = true ) {
25
+ [ CLSCompliant ( false ) ]
26
+ public static LogEventBuilder Critical ( this LogEventBuilder builder , bool isCritical = true ) {
14
27
return isCritical ? builder . Tag ( "Critical" ) : builder ;
15
28
}
16
29
@@ -19,8 +32,11 @@ public static LogBuilder Critical(this LogBuilder builder, bool isCritical = tru
19
32
/// </summary>
20
33
/// <param name="builder">The log builder object.</param>
21
34
/// <param name="tags">The tags to be added to the event.</param>
22
- public static LogBuilder Tag ( this LogBuilder builder , params string [ ] tags ) {
23
- builder . LogEventInfo . AddTags ( tags ) ;
35
+ [ CLSCompliant ( false ) ]
36
+ public static LogEventBuilder Tag ( this LogEventBuilder builder , params string [ ] tags ) {
37
+ if ( builder . LogEvent != null )
38
+ builder . LogEvent . AddTags ( tags ) ;
39
+
24
40
return builder ;
25
41
}
26
42
@@ -29,7 +45,8 @@ public static LogBuilder Tag(this LogBuilder builder, params string[] tags) {
29
45
/// </summary>
30
46
/// <param name="builder">The log builder object.</param>
31
47
/// <param name="identity">The user's identity that the event happened to.</param>
32
- public static LogBuilder Identity ( this LogBuilder builder , string identity ) {
48
+ [ CLSCompliant ( false ) ]
49
+ public static LogEventBuilder Identity ( this LogEventBuilder builder , string identity ) {
33
50
return builder . Identity ( identity , null ) ;
34
51
}
35
52
@@ -39,15 +56,18 @@ public static LogBuilder Identity(this LogBuilder builder, string identity) {
39
56
/// <param name="builder">The log builder object.</param>
40
57
/// <param name="identity">The user's identity that the event happened to.</param>
41
58
/// <param name="name">The user's friendly name that the event happened to.</param>
42
- public static LogBuilder Identity ( this LogBuilder builder , string identity , string name ) {
59
+ [ CLSCompliant ( false ) ]
60
+ public static LogEventBuilder Identity ( this LogEventBuilder builder , string identity , string name ) {
43
61
if ( String . IsNullOrWhiteSpace ( identity ) && String . IsNullOrWhiteSpace ( name ) )
44
62
return builder ;
45
63
46
64
return builder . Property ( Event . KnownDataKeys . UserInfo , new UserInfo ( identity , name ) ) ;
47
65
}
48
66
49
- public static LogBuilder ContextProperty ( this LogBuilder builder , string key , object value ) {
50
- builder . LogEventInfo . SetContextDataProperty ( key , value ) ;
67
+ [ CLSCompliant ( false ) ]
68
+ public static LogEventBuilder ContextProperty ( this LogEventBuilder builder , string key , object value ) {
69
+ if ( builder . LogEvent != null )
70
+ builder . LogEvent . SetContextDataProperty ( key , value ) ;
51
71
52
72
return builder ;
53
73
}
@@ -57,10 +77,14 @@ public static LogBuilder ContextProperty(this LogBuilder builder, string key, ob
57
77
/// </summary>
58
78
/// <param name="builder">The log builder object.</param>
59
79
/// <param name="submissionMethod">The submission method.</param>
60
- public static LogBuilder MarkUnhandled ( this LogBuilder builder , string submissionMethod = null ) {
61
- builder . LogEventInfo . SetContextDataProperty ( IsUnhandledError , true ) ;
80
+ [ CLSCompliant ( false ) ]
81
+ public static LogEventBuilder MarkUnhandled ( this LogEventBuilder builder , string submissionMethod = null ) {
82
+ if ( builder . LogEvent != null )
83
+ return builder ;
84
+
85
+ builder . LogEvent . SetContextDataProperty ( IsUnhandledError , true ) ;
62
86
if ( ! String . IsNullOrEmpty ( submissionMethod ) )
63
- builder . LogEventInfo . SetContextDataProperty ( SubmissionMethod , submissionMethod ) ;
87
+ builder . LogEvent . SetContextDataProperty ( SubmissionMethod , submissionMethod ) ;
64
88
65
89
return builder ;
66
90
}
0 commit comments