VB.NET • Trace Methodically

Listing 1. Each issue you trace using the library has a set of methods. In this case, an overloaded method lets you override the trace level for the issue—rare, because the defaults provide consistency.

Public Shared Sub ParamStringRequired( _
	ByVal paramName As String, _
	ByVal val As String)
	Dim traceLevel As traceLevel = _
		traceLevel.Error
	If (TSLevel.Level >= traceLevel) Then
		If (val Is Nothing OrElse val = "") Then
			ParamStringRequiredFailed(paramName, _
				traceLevel, val, _
				New StackFrame(1, True))
		End If
	End If
End Sub
Public Shared Sub ParamStringRequired( _
	ByVal paramName As String, _
	ByVal traceLevel As TraceLevel, _
	ByVal val As String)
	If (TSLevel.Level >= traceLevel) Then
		If (val Is Nothing OrElse val Is "") Then
			ParamStringRequiredFailed(paramName, _
				traceLevel, val, _
				New StackFrame(1, True))
		End If
	End If
End Sub
Private Shared Sub ParamStringRequiredFailed( _
	ByVal paramName As String, _
	ByVal traceLevel As TraceLevel, _
	ByVal val As String, _
	ByVal stackframe As StackFrame)
	TraceEntry(stackframe, traceLevel, val, _
		paramName, Nothing, _
		TraceIssues.ParamStringRequired, _
		"Parameter " & paramName & _
		" must have a length > 0 ")
End Sub