Skip to content

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 Const format 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 by clsLogAudit/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 are Friend-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) returns True when System.Web.HttpContext.Current is not Nothing, and gates whether ToFile() on clsLogAudit/clsLogError/clsLogTrace is permitted (see BR-003).
  • GetAppEnvironment/GetWebAppName (both Friend 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 the Logging assembly, used to populate trace/context info.
  • GetStateInfo (Friend Shared) renders caller-supplied ParamArray objects to text: primitives are rendered via ToString, and other objects are rendered property-by-property using STATEFMTCOMPLEX.
  • GetToFileName (Friend Shared) builds a temp-directory log file name using TOFILEFORMAT, the current process's main module name, and the current date.

Constraints and usage notes

  • Only the six Public Const members are usable from outside the SAIF.BOF.Framework.Logging assembly; the properties and methods described above are Friend-scoped and are internal implementation details shared by clsLogAudit, clsLogError, and clsLogTrace.
  • 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