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