clsLogCommon¶
clsLogCommon is a Public shared helper class that centralizes format-string constants and web/non-web context detection used by clsLogAudit, clsLogError, and clsLogTrace. The class itself is public, but its helper methods and properties are Friend-scoped (assembly-internal); only its Public Const members are part of the external public surface.
Purpose¶
- Expose shared
Public Constformat strings used to render error, state, and log-file-name text consistently across the logging entry points. - Provide
Friend-scoped web/non-web context detection (IsWeb), environment/application-name derivation, calling-method reflection, and log-file naming, used internally byclsLogAudit/clsLogError/clsLogTrace.
Context¶
- Namespace:
SAIF.Framework.Logging - Assembly/package:
SAIF.BOF.Framework.Logging(SAIF.Framework.Logging/SAIF.BOF.Framework.Logging.vbproj) - The class declaration is
Public Class clsLogCommon; its constants are public, while its Shared properties/methods areFriend-scoped.
Public members¶
| Member | Signature | Purpose |
|---|---|---|
ERRORTOSTRINGFORMAT |
Public Const ERRORTOSTRINGFORMAT As String = "{0,-20}: {1}{2}" |
Format string used when rendering an individual error field to text. |
EXCEPTIONINFOFORMAT |
Public Const EXCEPTIONINFOFORMAT As String |
Format string used to render exception message/source/stack-trace detail (used by ErrorInfoStruct). |
MSGSUBJECT |
Public Const MSGSUBJECT As String = "Error in App: {0}; Machine: {1}; Environ: {2}" |
Format string for the subject line of error-notification emails. |
STATEFMTSIMPLE |
Public Const STATEFMTSIMPLE As String = "{0,-20}= {1}" & vbCrLf |
Format string for a simple name/value state line (used by ErrorInfoStruct.ToString/ToHTMLString). |
STATEFMTCOMPLEX |
Public Const STATEFMTCOMPLEX As String = "{0,-20}({1})= {2}" & vbCrLf |
Format string for a name/type/value state line, used by GetStateInfo when rendering non-primitive caller-supplied objects. |
TOFILEFORMAT |
Public Const TOFILEFORMAT As String = "{0}\{1}_{2}_{3:MM}_{4:yyyy}.log" |
Format string used to build a local log file name/path. |
Behavioral notes¶
IsWeb(Friend Shared ReadOnly Property) returnsTruewhenSystem.Web.HttpContext.Currentis notNothing, and gates whetherToFile()onclsLogAudit/clsLogError/clsLogTraceis permitted (see BR-003).GetAppEnvironment/GetWebAppName(bothFriend Shared) derive an environment/application name by parsing the physical file/module path (splitting on:and\) rather than reading explicit configuration, an inferred convention rather than a documented contract*.GetCallingMethodInfo(Friend Shared) walks the current stack trace via reflection to find the first frame outside theLoggingassembly, used to populate trace/context info.GetStateInfo(Friend Shared) renders caller-suppliedParamArrayobjects to text: primitives are rendered viaToString, and other objects are rendered property-by-property usingSTATEFMTCOMPLEX.GetToFileName(Friend Shared) builds a temp-directory log file name usingTOFILEFORMAT, the current process's main module name, and the current date.
Constraints and usage notes¶
- Only the six
Public Constmembers are usable from outside theSAIF.BOF.Framework.Loggingassembly; the properties and methods described above areFriend-scoped and are internal implementation details shared byclsLogAudit,clsLogError, andclsLogTrace. - Consumers should not depend on the
Friend-scoped members remaining stable, since they are not part of the documented external contract.
Note: Statements marked with
*were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with**could not be confirmed; treat as unknown until verified.
Sources¶
SAIF.Framework.Logging/clsLogCommon.vb