No description
Find a file
Ethan Lane 9034392e1d
Add the ability to log to Git issues via webhook (#3) (#4)
#1

Reviewed-on: #3
Co-authored-by: Ethan Lane <ethan@vylpes.com>
Co-committed-by: Ethan Lane <ethan@vylpes.com>

Reviewed-on: #4
2026-02-18 18:20:20 +00:00
.github Add the ability to log to Git issues via webhook (#3) (#4) 2026-02-18 18:20:20 +00:00
src Add the ability to log to Git issues via webhook (#3) (#4) 2026-02-18 18:20:20 +00:00
.env.example Add the ability to log to Git issues via webhook (#3) (#4) 2026-02-18 18:20:20 +00:00
.gitignore Add the ability to log to Git issues via webhook (#3) (#4) 2026-02-18 18:20:20 +00:00
package-lock.json Add the ability to log to Git issues via webhook (#3) (#4) 2026-02-18 18:20:20 +00:00
package.json Initial commit 2025-04-22 16:59:55 +01:00
pm2.sh Initial commit 2025-04-22 16:59:55 +01:00
README.md Add the ability to log to Git issues via webhook (#3) (#4) 2026-02-18 18:20:20 +00:00
tsconfig.json Initial commit 2025-04-22 16:59:55 +01:00
yarn.lock Add the ability to log to Git issues via webhook (#3) (#4) 2026-02-18 18:20:20 +00:00

server-logger

Simple Express-based logging server with optional Discord log forwarding and optional Forgejo issue creation.

Features

  • Accepts webhook-style log events on /info, /warn, and /error
  • Writes logs to rotating files (winston-daily-rotate-file)
  • Mirrors logs to console
  • Sends logs to Discord webhook
  • Optionally creates a Forgejo issue from req.body.git

Requirements

  • Node.js 18+ (Node 20+ recommended)
  • npm

Setup

  1. Install dependencies:
npm install
  1. Create your env file from the example and set values:
cp .env.example .env
  1. Build:
npm run build
  1. Run:
npm start

Environment Variables

  • EXPRESS_PORT: Port for the HTTP server
  • LOG_DIR: Directory where rotating log files are written
  • LOG_DISCORD_WEBHOOK: Discord webhook URL for log transport
  • FORGEJO_ISSUE_WEBHOOK: Webhook URL used to create Forgejo issues
  • FORGEJO_TOKEN: Forgejo API token for authenticated issue creation

FORGEJO_ISSUE_WEBHOOK behavior

  • If empty, Git issue creation is skipped.
  • If it contains {owner} and/or {repo}, values are read from req.body.git.owner and req.body.git.repo and injected into those tokens.
  • If it does not contain {owner} or {repo}, the exact URL is used for all requests.
  • FORGEJO_TOKEN is sent in the Authorization header (default format: token <TOKEN>).

API

Endpoints

  • POST /info
  • POST /warn
  • POST /error

Base JSON body

{
  "service": "my-service",
  "message": "Something happened"
}

Optional Git issue payload

Include git only when you want to create a Forgejo issue:

{
  "service": "my-service",
  "message": "Unhandled error in worker",
  "git": {
    "owner": "my-user",
    "repo": "my-repo",
    "title": "Worker crashed while processing queue",
    "description": "Stack trace and context here",
    "labels": ["bug", "backend"],
    "assignees": ["my-user"]
  }
}

git validation rules

  • owner: required, non-empty string
  • repo: required, non-empty string
  • title: required, non-empty string
  • description: required, non-empty string
  • labels: optional, array of non-empty strings
  • assignees: optional, array of non-empty strings

If git is missing, normal logging still works and no issue is created.