# runsystemid/golog architecture

> Architecture diagram of the GitHub repository runsystemid/golog, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/runsystemid/golog
- Repository: https://github.com/runsystemid/golog

## Overview

##### Project type and purpose
- Golog is a Go library (an open-source logging tool), not a standalone service or web application.
- Its purpose is to provide a standardized, configurable logging façade for Runsystem services with two output streams (system log and TDR log), log rotation, and console-stdout toggling.

##### File structure
- Top-level Go files:
- loader.go – initializes the logging subsystem with a Config struct
- logger.go – exposes logging methods (Info, Error, Debug, Warn, Fatal, Panic)
- service.go – implements the actual writing/rotation of log entries to files
- model.go – defines the log message schema/structs (fields: traceId, srcIP, port, path, etc.)
- helper.go – context helpers to extract and attach metadata (traceId, srcIP, …)
- go.mod / go.sum – module dependencies
- README.md, CONTRIBUTING.md, LICENSE – documentation and governance

##### README for additional insights
- Configuration options: App, AppVer, Env, FileLocation, FileTDRLocation, FileMaxSize, FileMaxBackup, FileMaxAge, Stdout.
- Usage pattern:
- Call golog.Loader(config) once at startup.
- Invoke golog.Info(ctx, msg) or other levels anywhere thereafter.
- Two output channels: system log (all levels) and TDR log (special events).

##### Detail without overthinking
- Two logical sinks (system/TDR) even if they reuse the same service layer.
- Config fields that drive behavior (stdout toggle, file rotation).

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Initialization"
        ConfigProvider["Config Provider"]:::init
        Loader["Loader"]:::init
    end

    subgraph "Runtime"
        Application["Application"]:::app
        ContextHelper["Context Helper"]:::runtime
        LoggerInterface["Logger Interface"]:::runtime
        LogModel["Log Model"]:::runtime
        LogService["Log Service"]:::runtime
    end

    subgraph "Outputs"
        FileSystem["File System"]:::external
        Stdout["Console Stdout"]:::external
    end

    subgraph "Module Dependencies"
        GoMod["go.mod"]:::doc
        GoSum["go.sum"]:::doc
    end

    subgraph "Documentation & Governance"
        README["README.md"]:::doc
        CONTRIB["CONTRIBUTING.md"]:::doc
        LICENSE["LICENSE"]:::doc
    end

    Application -->|calls at startup| ConfigProvider
    ConfigProvider -->|reads config| Loader
    Loader -->|initializes Logger| LoggerInterface

    Application -->|enriches context| ContextHelper
    ContextHelper -->|provides ctx| LoggerInterface
    LoggerInterface -->|builds model| LogModel
    LogModel -->|hands to| LogService
    LogService -->|writes to| FileSystem
    LogService -->|writes to| Stdout

    click Loader "https://github.com/runsystemid/golog/blob/main/loader.go"
    click LoggerInterface "https://github.com/runsystemid/golog/blob/main/logger.go"
    click ContextHelper "https://github.com/runsystemid/golog/blob/main/helper.go"
    click LogModel "https://github.com/runsystemid/golog/blob/main/model.go"
    click LogService "https://github.com/runsystemid/golog/blob/main/service.go"
    click GoMod "https://github.com/runsystemid/golog/blob/main/go.mod"
    click GoSum "https://github.com/runsystemid/golog/blob/main/go.sum"
    click README "https://github.com/runsystemid/golog/blob/main/README.md"
    click CONTRIB "https://github.com/runsystemid/golog/blob/main/CONTRIBUTING.md"
    click LICENSE "https://github.com/runsystemid/golog/tree/main/LICENSE"

    classDef init fill:#0074D9,stroke:#001f3f,color:#ffffff;
    classDef runtime fill:#2ECC40,stroke:#228B22,color:#000000;
    classDef external fill:#AAAAAA,stroke:#888888,color:#000000;
    classDef app fill:#FF851B,stroke:#7F5217,color:#000000;
    classDef doc fill:#DDDDDD,stroke:#BBBBBB,color:#000000;

    linkStyle 0 stroke:#0000ff,stroke-width:2px;
    linkStyle 1 stroke:#0000ff,stroke-width:2px;
    linkStyle 2 stroke:#0000ff,stroke-width:2px;
    linkStyle 3 stroke:#00ff00,stroke-width:2px;
    linkStyle 4 stroke:#00ff00,stroke-width:2px;
    linkStyle 5 stroke:#00ff00,stroke-width:2px;
    linkStyle 6 stroke:#00ff00,stroke-width:2px;
    linkStyle 7 stroke:#00ff00,stroke-width:2px;
    linkStyle 8 stroke:#00ff00,stroke-width:2px;
```
