diff options
| author | Yuqian Yang <crupest@crupest.life> | 2025-06-17 15:14:48 +0800 | 
|---|---|---|
| committer | Yuqian Yang <crupest@crupest.life> | 2025-06-17 21:37:43 +0800 | 
| commit | 1cea9d856f4904f0d62b568d9c0d31871d0fcd8a (patch) | |
| tree | 6e7b30da64b18a42421831be7ede238815c9cf1e /deno/base | |
| parent | f160809fabe9241867c7e3831351201f3df6c768 (diff) | |
| download | crupest-1cea9d856f4904f0d62b568d9c0d31871d0fcd8a.tar.gz crupest-1cea9d856f4904f0d62b568d9c0d31871d0fcd8a.tar.bz2 crupest-1cea9d856f4904f0d62b568d9c0d31871d0fcd8a.zip | |
mail: skip saving if cc myself, mark sent as read.
Diffstat (limited to 'deno/base')
| -rw-r--r-- | deno/base/deno.json | 1 | ||||
| -rw-r--r-- | deno/base/log.ts | 60 | 
2 files changed, 0 insertions, 61 deletions
| diff --git a/deno/base/deno.json b/deno/base/deno.json index dabc02a..52baaa5 100644 --- a/deno/base/deno.json +++ b/deno/base/deno.json @@ -5,6 +5,5 @@      ".": "./lib.ts",      "./config": "./config.ts",      "./cron": "./cron.ts", -    "./log": "./log.ts"    }  } diff --git a/deno/base/log.ts b/deno/base/log.ts deleted file mode 100644 index 940f569..0000000 --- a/deno/base/log.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { join } from "@std/path"; - -import { toFileNameString } from "./lib.ts"; - -export interface ExternalLogStream extends Disposable { -  stream: WritableStream; -} - -export class LogFileProvider { -  #directory: string; - -  constructor(directory: string) { -    this.#directory = directory; -    Deno.mkdirSync(directory, { recursive: true }); -  } - -  async createExternalLogStream( -    name: string, -    options?: { -      noTime?: boolean; -    }, -  ): Promise<ExternalLogStream> { -    if (name.includes("/")) { -      throw new Error(`External log stream's name (${name}) contains '/'.`); -    } - -    const logPath = join( -      this.#directory, -      options?.noTime === true -        ? name -        : `${name}-${toFileNameString(new Date())}`, -    ); - -    const file = await Deno.open(logPath, { -      read: false, -      write: true, -      append: true, -      create: true, -    }); -    return { -      stream: file.writable, -      [Symbol.dispose]: file[Symbol.dispose].bind(file), -    }; -  } - -  async createExternalLogStreamsForProgram( -    program: string, -  ): Promise<{ stdout: WritableStream; stderr: WritableStream } & Disposable> { -    const stdout = await this.createExternalLogStream(`${program}-stdout`); -    const stderr = await this.createExternalLogStream(`${program}-stderr`); -    return { -      stdout: stdout.stream, -      stderr: stderr.stream, -      [Symbol.dispose]: () => { -        stdout[Symbol.dispose](); -        stderr[Symbol.dispose](); -      }, -    }; -  } -} | 
