@@ -15,8 +15,6 @@ public static class Keywords
1515 [ EventSource ( Name = "rabbitmq-client-stream" ) ]
1616 internal sealed class LogEventSource : EventSource , ILogEventSource
1717 {
18- private static readonly char [ ] _newLineChars = Environment . NewLine . ToCharArray ( ) ;
19-
2018 /// <summary>
2119 /// Default <see cref="LogEventSource" /> implementation for logging.
2220 /// </summary>
@@ -33,7 +31,7 @@ private LogEventSource() : base(EventSourceSettings.EtwSelfDescribingEventFormat
3331 [ NonEvent ]
3432 private static string ConvertToString ( Exception exception )
3533 {
36- return exception ? . ToString ( ) ;
34+ return exception == default ? default : $ " { Environment . NewLine } { exception ? . ToString ( ) } " ;
3735 }
3836
3937 /// <summary>
@@ -42,7 +40,7 @@ private static string ConvertToString(Exception exception)
4240 ///
4341 /// <param name="message">
4442 /// </param>
45- [ Event ( 1 , Level = EventLevel . Informational ) ]
43+ [ Event ( 1 , Message = "INFO" , Keywords = Keywords . Log , Level = EventLevel . Informational ) ]
4644 public ILogEventSource LogInformation ( string message )
4745 {
4846 if ( IsEnabled ( ) )
@@ -53,13 +51,28 @@ public ILogEventSource LogInformation(string message)
5351 return this ;
5452 }
5553
54+ /// <summary>
55+ /// Writes an informational log message.
56+ /// </summary>
57+ ///
58+ /// <param name="message">
59+ /// </param>
60+ ///
61+ /// <param name="args">
62+ /// </param>
63+ [ NonEvent ]
64+ public ILogEventSource LogInformation ( string message , params object [ ] args )
65+ {
66+ return LogInformation ( string . Format ( message , args ) ) ;
67+ }
68+
5669 /// <summary>
5770 /// Writes a warning log message.
5871 /// </summary>
5972 ///
6073 /// <param name="message">
6174 /// </param>
62- [ Event ( 2 , Level = EventLevel . Warning ) ]
75+ [ Event ( 2 , Message = "WARN" , Keywords = Keywords . Log , Level = EventLevel . Warning ) ]
6376 public ILogEventSource LogWarning ( string message )
6477 {
6578 if ( IsEnabled ( ) )
@@ -70,13 +83,27 @@ public ILogEventSource LogWarning(string message)
7083 return this ;
7184 }
7285
86+ /// <summary>
87+ /// Writes a warning log message.
88+ /// </summary>
89+ ///
90+ /// <param name="message">
91+ /// </param>
92+ ///
93+ /// <param name="args">
94+ /// </param>
95+ public ILogEventSource LogWarning ( string message , params object [ ] args )
96+ {
97+ return LogWarning ( string . Format ( message , args ) ) ;
98+ }
99+
73100 /// <summary>
74101 /// Writes an error log message.
75102 /// </summary>
76103 ///
77104 /// <param name="message">
78105 /// </param>
79- [ Event ( 3 , Level = EventLevel . Error ) ]
106+ [ Event ( 3 , Message = "ERROR" , Keywords = Keywords . Log , Level = EventLevel . Error ) ]
80107 public ILogEventSource LogError ( string message )
81108 {
82109 if ( IsEnabled ( ) )
@@ -100,9 +127,28 @@ public ILogEventSource LogError(string message)
100127 [ NonEvent ]
101128 public ILogEventSource LogError ( string message , Exception exception )
102129 {
103- LogError ( $ "{ message } { Environment . NewLine } { ConvertToString ( exception ) } " . Trim ( _newLineChars ) ) ;
130+ LogError ( $ "{ message } { ConvertToString ( exception ) } " ) ;
104131
105132 return this ;
106133 }
134+
135+ /// <summary>
136+ /// Writes an error log message.
137+ /// </summary>
138+ ///
139+ /// <param name="message">
140+ /// </param>
141+ ///
142+ /// <param name="exception">
143+ /// The exception to log.
144+ /// </param>
145+ ///
146+ /// <param name="args">
147+ /// </param>
148+ [ NonEvent ]
149+ public ILogEventSource LogError ( string message , Exception exception , params object [ ] args )
150+ {
151+ return LogError ( string . Format ( message , args ) , exception ) ;
152+ }
107153 }
108154}
0 commit comments