Skip to content

📄 $log – Structured Logging API

The $log API provides a simple, structured logging mechanism for plugins.

It automatically enriches logs with:

  • plugin context
  • timestamps
  • consistent formatting

🧠 Core Concept

ts
$log(title, message, level)
  • title → short label
  • message → any data (string, object, etc.)
  • level → log level (number)

🔧 Basic Usage

ts
$log("init", "Component mounted", 1)

🧩 Examples

Logging a string

ts
$log("hallo", "dings", 1)

Console output:

plugin/<plugin-name> - hallo

{
  message: "dings",
  dateTime: "21.04.2026 - 17:30:40:615"
}

Logging an object

ts
$log("hallo", { title: "test" }, 1)

⚙️ Behavior

  • Automatically prefixes:

    plugin/<pluginKey> - <title>
  • Adds timestamp (dateTime)

  • Accepts any message type


🧠 Log Levels

Typical convention (can vary by setup):

  • 0 → error
  • 1 → info
  • 2 → debug

🧠 Mental Model

  • $log = structured console.log
  • consistent format across plugins
  • enriched with plugin context

⚖️ When to Use $log

Use $log for:

  • debugging plugin logic
  • tracing events
  • logging API responses
  • development insights

🚫 Important Notes

  • Not intended for user-facing messages
  • Use $eventbus or UI notifications instead
  • Avoid excessive logging in production

🧠 Key Takeaway

$log gives you clean, contextual, and consistent debugging output