Color mode

Search notes

Filter with tag:, lang:, or path:.

ログとトレースを出す

運用メッセージには context.logger、プロファイラーが集計できる計測には context.tracer を使います。ロガーのコンテキスト値は文字列、数値、真偽値、null のいずれかです。

ts
import { definePlugin } from "@riebeckite/core";
 
export function timed() {
  return definePlugin({
    name: "timed",
    buildStart: async ({ logger, tracer }) => {
      const log = logger.child({ plugin: "timed" });
      log.info("Preparing the example plugin");
 
      await tracer.span("example.prepare", { plugin: "timed" }, async () => {
        log.debug("Running the preparation step");
      });
    },
  });
}

自前のタイマーを回して結果を表示しないでください。プロファイラーは構造化されたスパンを読み、その場限りの出力は通常のログレベルを迂回します。


プラグイン機能別レシピに戻る · Plugin API