@@ -23,15 +23,56 @@ public static ExceptionlessLogLevel ToLogLevel(this LogLevel level) {
23
23
24
24
return ExceptionlessLogLevel . Off ;
25
25
}
26
+ /// <summary>
27
+ /// Adds Exceptionless to the logging pipeline using the <see cref="ExceptionlessClient.Default"/>.
28
+ /// </summary>
29
+ /// <param name="builder">The <see cref="ILoggingBuilder"/>.</param>
30
+ /// <param name="client">If a client is not specified then the <see cref="ExceptionlessClient.Default"/> wil be used.</param>
31
+ /// <returns>The <see cref="ILoggingBuilder"/>.</returns>
32
+ public static ILoggingBuilder AddExceptionless ( this ILoggingBuilder builder , ExceptionlessClient client = null ) {
33
+ builder . AddProvider ( new ExceptionlessLoggerProvider ( client ?? ExceptionlessClient . Default ) ) ;
34
+ return builder ;
35
+ }
36
+ /// <summary>
37
+ /// Adds Exceptionless to the logging pipeline using a new client with the provided api key.
38
+ /// </summary>
39
+ /// <param name="builder">The <see cref="ILoggingBuilder"/>.</param>
40
+ /// <param name="apiKey">The project api key.</param>
41
+ /// <param name="serverUrl">The Server Url.</param>
42
+ /// <returns>The <see cref="ILoggingBuilder"/>.</returns>
43
+ public static ILoggingBuilder AddExceptionless ( this ILoggingBuilder builder , string apiKey , string serverUrl = null ) {
44
+ if ( String . IsNullOrEmpty ( apiKey ) && String . IsNullOrEmpty ( serverUrl ) )
45
+ return builder . AddExceptionless ( ) ;
26
46
27
- // TODO: Add support for ILoggingBuilder
47
+ builder . AddProvider ( new ExceptionlessLoggerProvider ( config => {
48
+ if ( ! String . IsNullOrEmpty ( apiKey ) && apiKey != "API_KEY_HERE" )
49
+ config . ApiKey = apiKey ;
50
+ if ( ! String . IsNullOrEmpty ( serverUrl ) )
51
+ config . ServerUrl = serverUrl ;
28
52
53
+ config . UseInMemoryStorage ( ) ;
54
+ } ) ) ;
55
+
56
+ return builder ;
57
+ }
29
58
/// <summary>
30
- /// Adds Exceptionless to the logging pipeline using the default client.
59
+ /// Adds Exceptionless to the logging pipeline using a new client configured with the provided action.
60
+ /// </summary>
61
+ /// <param name="builder">The <see cref="ILoggingBuilder"/>.</param>
62
+ /// <param name="configure">An <see cref="Action{ExceptionlessConfiguration}"/> that applies additional settings and plugins. The project api key must be specified.</param>
63
+ /// <returns>The <see cref="ILoggerFactory"/>.</returns>
64
+ public static ILoggingBuilder AddExceptionless ( this ILoggingBuilder builder , Action < ExceptionlessConfiguration > configure ) {
65
+ builder . AddProvider ( new ExceptionlessLoggerProvider ( configure ) ) ;
66
+ return builder ;
67
+ }
68
+ #region Obsolute
69
+ /// <summary>
70
+ /// Adds Exceptionless to the logging pipeline using the <see cref="ExceptionlessClient.Default"/>.
31
71
/// </summary>
32
72
/// <param name="factory">The <see cref="ILoggerFactory"/>.</param>
33
- /// <param name="client">If a client is not specified than the default instance will be used.</param>
73
+ /// <param name="client">If a client is not specified then the <see cref="ExceptionlessClient.Default"/> wil be used.</param>
34
74
/// <returns>The <see cref="ILoggerFactory"/>.</returns>
75
+ [ Obsolete ( "Use ExceptionlessLoggerExtensions.AddExceptionless(ILoggingBuilder,ExceptionlessClient) instead." ) ]
35
76
public static ILoggerFactory AddExceptionless ( this ILoggerFactory factory , ExceptionlessClient client = null ) {
36
77
factory . AddProvider ( new ExceptionlessLoggerProvider ( client ?? ExceptionlessClient . Default ) ) ;
37
78
return factory ;
@@ -44,6 +85,7 @@ public static ILoggerFactory AddExceptionless(this ILoggerFactory factory, Excep
44
85
/// <param name="apiKey">The project api key.</param>
45
86
/// <param name="serverUrl">The Server Url</param>
46
87
/// <returns>The <see cref="ILoggerFactory"/>.</returns>
88
+ [ Obsolete ( "Use ExceptionlessLoggerExtensions.AddExceptionless(ILoggingBuilder,string,string) instead." ) ]
47
89
public static ILoggerFactory AddExceptionless ( this ILoggerFactory factory , string apiKey , string serverUrl = null ) {
48
90
if ( String . IsNullOrEmpty ( apiKey ) && String . IsNullOrEmpty ( serverUrl ) )
49
91
return factory . AddExceptionless ( ) ;
@@ -66,9 +108,11 @@ public static ILoggerFactory AddExceptionless(this ILoggerFactory factory, strin
66
108
/// <param name="factory">The <see cref="ILoggerFactory"/>.</param>
67
109
/// <param name="configure">An <see cref="Action{ExceptionlessConfiguration}"/> that applies additional settings and plugins. The project api key must be specified.</param>
68
110
/// <returns>The <see cref="ILoggerFactory"/>.</returns>
111
+ [ Obsolete ( "Use ExceptionlessLoggerExtensions.AddExceptionless(ILoggingBuilder,Action<ExceptionlessConfiguration>) instead." ) ]
69
112
public static ILoggerFactory AddExceptionless ( this ILoggerFactory factory , Action < ExceptionlessConfiguration > configure ) {
70
113
factory . AddProvider ( new ExceptionlessLoggerProvider ( configure ) ) ;
71
114
return factory ;
72
- }
115
+ }
116
+ #endregion
73
117
}
74
118
}
0 commit comments