Skip to content

Write to the console/application log (contract only)

Define (without implementing) a console/file logging contract, triggered when a consuming console/batch application writes progress, errors, or exception detail to one or more log files*.

Field Value
Operation ID OP-038
Trigger A consuming console/batch application writes progress, errors, or exception detail to one or more log files*
Inputs message, logId or LogType, filePath, Exception
Outputs Log output (implementation-defined)
Primary components SAIF.Common.Interfaces.IConsoleLogService` and `SAIF.Common.Interfaces.ILogWriter
Entry point Common/SAIF.Common/Interfaces/IConsoleLogService.cs

Steps

  1. The application registers a log file against a string logId using RegisterLogFile(logId, filePath). (BR-091)
  2. It retrieves an ILogWriter by string id (GetLog(string)) or by the LogType enum (GetLog(LogType) — File0-File4 or Custom), or enumerates them all via Logs. (BR-091, BR-092)
  3. It writes through Write/WriteError (service level) or Write/WriteLine/WriteTimedLine (writer level). WriteToAppLog(message, logId, bool line = true) defaults to appending a line break, while WriteToAppLog(message, LogType, bool line = false) defaults to not appending one. (BR-093)
  4. Timestamp rendering on WriteTimedLine is configured per writer through SetTimeFormat, SetTimeDelimiter, and SetWriteLinePrefix. (BR-091)
  5. LogException(Exception) records an exception; buffered output is pushed with Flush(), Flush(logId), or Flush(LogType). (BR-091)
  6. Both interfaces extend IDisposable, so the application is expected to dispose the service (and thereby its writers) at shutdown. (BR-094)

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    Start(["Consuming app writes progress,<br>errors, or exception detail"]) --> S1["Register a log file against<br>logId via RegisterLogFile"]
    S1 --> S2["Retrieve an ILogWriter by string id,<br>by the LogType enum, or<br>enumerate all via Logs"]
    S2 --> S3["Write via Write/WriteError,<br>or WriteToAppLog (line-break<br>default varies by overload)"]
    S3 --> S4["Configure timestamp rendering per<br>writer via SetTimeFormat,<br>SetTimeDelimiter, SetWriteLinePrefix"]
    S4 --> S5["LogException records an exception;<br>Flush pushes buffered output"]
    S5 --> S6["Application disposes the service<br>and its writers at shutdown"]
    S6 --> End(["Log output written and<br>resources released"])

Failure and edge-case behavior

  • These are contracts only — this library provides no implementation of IConsoleLogService or ILogWriter. The step sequence above describes the contract's intended usage, inferred from the member signatures; the actual behavior is defined by whichever consuming assembly implements them.*

Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.

Sources

  • Common/SAIF.Common/Interfaces/IConsoleLogService.cs
  • Common/SAIF.Common/Interfaces/ILogWriter.cs
  • Common/SAIF.Common/Enums/LogType.cs