Skip to main content
Code Review

Return to Question

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

This FileLogger uses a TextWriter object that handles opening, writing and closing files - it's out of scope for this post, but it's reviewable here here.

This FileLogger uses a TextWriter object that handles opening, writing and closing files - it's out of scope for this post, but it's reviewable here.

This FileLogger uses a TextWriter object that handles opening, writing and closing files - it's out of scope for this post, but it's reviewable here.

edited tags
Link
Mathieu Guindon
  • 75.5k
  • 18
  • 194
  • 467
deleted 129 characters in body
Source Link
Mathieu Guindon
  • 75.5k
  • 18
  • 194
  • 467

The ILogger interface merely stipulates that a logger has a name andmin level property, and a Log method accepting a LogLevel and a messagethe formatted log output:

Option Explicit

Option Explicit
Public Sub Log(ByVal output As String)
End Sub
Public Property Get loggerNameName() As String
End Property
Public Property Get MinLevel() As LogLevel
End Property

The client code could implement ILogger differently, and make one that writes TRACE, DEBUG and INFOlog entries to the immediate paneinto, say, a database. WARNFileLogger and ERROR entries to a file, and FATAL entries could cause an email to be sent via Outlook: it's just an interface, the implementation does the real work, DebugLogger and FileLogger just so happen to be useful enoughare provided for most usagesconvenience, so the client code most often doesn't need to implement thebut nothing forbids implementing and registering custom ILogger interfaces on the client side.

2014年09月28日 19:2242:3344 TestLogger [ERROR] Division by zero

The ILogger interface merely stipulates that a logger has a name and a Log method accepting a LogLevel and a message:

Option Explicit
Public Sub Log(ByVal output As String)
End Sub
Public Property Get loggerName() As String
End Property

The client code could implement ILogger differently, and make one that writes TRACE, DEBUG and INFO entries to the immediate pane, WARN and ERROR entries to a file, and FATAL entries could cause an email to be sent via Outlook: it's just an interface, the implementation does the real work, DebugLogger and FileLogger just so happen to be useful enough for most usages, so the client code most often doesn't need to implement the ILogger interface.

2014年09月28日 19:22:33 TestLogger [ERROR] Division by zero

The ILogger interface merely stipulates that a logger has a name andmin level property, and a Log method accepting the formatted log output:

Option Explicit

Public Sub Log(ByVal output As String)
End Sub
Public Property Get Name() As String
End Property
Public Property Get MinLevel() As LogLevel
End Property

The client code could implement ILogger differently, and make one that writes log entries into, say, a database. FileLogger and DebugLogger are provided for convenience, but nothing forbids implementing and registering custom ILoggers on the client side.

2014年09月28日 19:42:44 TestLogger [ERROR] Division by zero
refactored...
Source Link
Mathieu Guindon
  • 75.5k
  • 18
  • 194
  • 467
Loading
added 1273 characters in body
Source Link
Mathieu Guindon
  • 75.5k
  • 18
  • 194
  • 467
Loading
Tweeted twitter.com/#!/StackCodeReview/status/516341618124013568
Source Link
Mathieu Guindon
  • 75.5k
  • 18
  • 194
  • 467
Loading
lang-vb

AltStyle によって変換されたページ (->オリジナル) /