Loading CHANGES.md +4 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,10 @@ Version 1.0.16 To be released. - The `fedify` command became aware of `FEDIFY_LOG_FILE` environment variable to log messages to a file. If the variable is set, the command logs messages to the file specified by the variable. Version 1.0.15 -------------- Loading cli/init.ts +2 −2 Original line number Diff line number Diff line Loading @@ -8,6 +8,8 @@ import { basename, dirname, join, normalize } from "@std/path"; import { format, greaterThan, parse } from "@std/semver"; import metadata from "./deno.json" with { type: "json" }; const logger = getLogger(["fedify", "cli", "init"]); type Runtime = "deno" | "bun" | "node"; interface RuntimeDescription { Loading Loading @@ -542,8 +544,6 @@ const messageQueues: Record<MessageQueue, MessageQueueDescription> = { }, } as const; const logger = getLogger(["fedify", "cli", "init"]); export const command = new Command() .type( "runtime", Loading cli/log.ts +14 −3 Original line number Diff line number Diff line import { configure, getConsoleSink, getFileSink, type LogRecord, type Sink, } from "@logtape/logtape"; import { dirname } from "@std/path"; export interface RecordingSink extends Sink { startRecording(): void; Loading @@ -30,19 +32,28 @@ export function getRecordingSink(): RecordingSink { export const recordingSink = getRecordingSink(); export const logFile = Deno.env.get("FEDIFY_LOG_FILE"); if (logFile != null) { await Deno.mkdir(dirname(logFile), { recursive: true }); } await configure({ sinks: { console: getConsoleSink(), recording: recordingSink }, sinks: { console: getConsoleSink(), recording: recordingSink, file: logFile == null ? () => undefined : getFileSink(logFile), }, filters: {}, loggers: [ { category: "fedify", level: "debug", sinks: ["recording"], sinks: ["recording", "file"], }, { category: ["logtape", "meta"], level: "warning", sinks: ["console"], sinks: ["console", "file"], }, ], reset: true, Loading cli/mod.ts +17 −6 Original line number Diff line number Diff line import { Command, CompletionsCommand, HelpCommand } from "@cliffy/command"; import { configure, getConsoleSink } from "@logtape/logtape"; import { configure, getConsoleSink, getFileSink } from "@logtape/logtape"; import { DEFAULT_CACHE_DIR, setCacheDir } from "./cache.ts"; import metadata from "./deno.json" with { type: "json" }; import { command as inbox } from "./inbox.tsx"; import { command as init } from "./init.ts"; import { recordingSink } from "./log.ts"; import { logFile, recordingSink } from "./log.ts"; import { command as lookup } from "./lookup.ts"; import { command as tunnel } from "./tunnel.ts"; const command = new Command() .name("fedify") .version(metadata.version) .globalEnv( "FEDIFY_LOG_FILE=<file:file>", "An optional file to write logs to. " + "Regardless of -d/--debug option, " + "all levels of logs are written to this file. " + "Note that this does not mute console logs.", ) .globalOption("-d, --debug", "Enable debug mode.", { async action() { await configure({ sinks: { console: getConsoleSink(), recording: recordingSink }, sinks: { console: getConsoleSink(), recording: recordingSink, file: logFile == null ? () => undefined : getFileSink(logFile), }, filters: {}, loggers: [ { category: "fedify", level: "debug", sinks: ["console", "recording"], sinks: ["console", "recording", "file"], }, { category: "localtunnel", level: "debug", sinks: ["console"], sinks: ["console", "file"], }, { category: ["logtape", "meta"], level: "warning", sinks: ["console"], sinks: ["console", "file"], }, ], reset: true, Loading Loading
CHANGES.md +4 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,10 @@ Version 1.0.16 To be released. - The `fedify` command became aware of `FEDIFY_LOG_FILE` environment variable to log messages to a file. If the variable is set, the command logs messages to the file specified by the variable. Version 1.0.15 -------------- Loading
cli/init.ts +2 −2 Original line number Diff line number Diff line Loading @@ -8,6 +8,8 @@ import { basename, dirname, join, normalize } from "@std/path"; import { format, greaterThan, parse } from "@std/semver"; import metadata from "./deno.json" with { type: "json" }; const logger = getLogger(["fedify", "cli", "init"]); type Runtime = "deno" | "bun" | "node"; interface RuntimeDescription { Loading Loading @@ -542,8 +544,6 @@ const messageQueues: Record<MessageQueue, MessageQueueDescription> = { }, } as const; const logger = getLogger(["fedify", "cli", "init"]); export const command = new Command() .type( "runtime", Loading
cli/log.ts +14 −3 Original line number Diff line number Diff line import { configure, getConsoleSink, getFileSink, type LogRecord, type Sink, } from "@logtape/logtape"; import { dirname } from "@std/path"; export interface RecordingSink extends Sink { startRecording(): void; Loading @@ -30,19 +32,28 @@ export function getRecordingSink(): RecordingSink { export const recordingSink = getRecordingSink(); export const logFile = Deno.env.get("FEDIFY_LOG_FILE"); if (logFile != null) { await Deno.mkdir(dirname(logFile), { recursive: true }); } await configure({ sinks: { console: getConsoleSink(), recording: recordingSink }, sinks: { console: getConsoleSink(), recording: recordingSink, file: logFile == null ? () => undefined : getFileSink(logFile), }, filters: {}, loggers: [ { category: "fedify", level: "debug", sinks: ["recording"], sinks: ["recording", "file"], }, { category: ["logtape", "meta"], level: "warning", sinks: ["console"], sinks: ["console", "file"], }, ], reset: true, Loading
cli/mod.ts +17 −6 Original line number Diff line number Diff line import { Command, CompletionsCommand, HelpCommand } from "@cliffy/command"; import { configure, getConsoleSink } from "@logtape/logtape"; import { configure, getConsoleSink, getFileSink } from "@logtape/logtape"; import { DEFAULT_CACHE_DIR, setCacheDir } from "./cache.ts"; import metadata from "./deno.json" with { type: "json" }; import { command as inbox } from "./inbox.tsx"; import { command as init } from "./init.ts"; import { recordingSink } from "./log.ts"; import { logFile, recordingSink } from "./log.ts"; import { command as lookup } from "./lookup.ts"; import { command as tunnel } from "./tunnel.ts"; const command = new Command() .name("fedify") .version(metadata.version) .globalEnv( "FEDIFY_LOG_FILE=<file:file>", "An optional file to write logs to. " + "Regardless of -d/--debug option, " + "all levels of logs are written to this file. " + "Note that this does not mute console logs.", ) .globalOption("-d, --debug", "Enable debug mode.", { async action() { await configure({ sinks: { console: getConsoleSink(), recording: recordingSink }, sinks: { console: getConsoleSink(), recording: recordingSink, file: logFile == null ? () => undefined : getFileSink(logFile), }, filters: {}, loggers: [ { category: "fedify", level: "debug", sinks: ["console", "recording"], sinks: ["console", "recording", "file"], }, { category: "localtunnel", level: "debug", sinks: ["console"], sinks: ["console", "file"], }, { category: ["logtape", "meta"], level: "warning", sinks: ["console"], sinks: ["console", "file"], }, ], reset: true, Loading