forked from supabase/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogs.command.ts
More file actions
63 lines (60 loc) · 2.61 KB
/
Copy pathlogs.command.ts
File metadata and controls
63 lines (60 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { DEFAULT_MANAGED_STACK_NAME } from "@supabase/stack/effect";
import { Command, Flag } from "effect/unstable/cli";
import type * as CliCommand from "effect/unstable/cli/Command";
import { withJsonErrorHandling } from "../../../shared/output/json-error-handling.ts";
import { commandRuntimeLayer } from "../../../shared/runtime/command-runtime.layer.ts";
import { withCommandInstrumentation } from "../../../shared/telemetry/command-instrumentation.ts";
import { logs } from "./logs.handler.ts";
const flags = {
stack: Flag.string("stack").pipe(
Flag.withDescription("Name of the managed local stack for this project."),
Flag.withDefault(DEFAULT_MANAGED_STACK_NAME),
),
tail: Flag.integer("tail").pipe(
Flag.filter(
(tail) => tail >= 0,
(tail) => `Expected --tail to be non-negative, got ${tail}`,
),
Flag.withDescription(
"Number of buffered log lines to print before following. Use 0 to skip history.",
),
Flag.withDefault(100),
),
service: Flag.string("service").pipe(
Flag.atMost(4),
Flag.withDescription(
"Filter by service name. Repeat the flag for multiple services (for example: --service postgres --service auth)",
),
Flag.withDefault([] as ReadonlyArray<string>),
),
noFollow: Flag.boolean("no-follow").pipe(
Flag.withDescription("Print buffered history only and exit without following live logs."),
),
} as const;
export type LogsFlags = CliCommand.Command.Config.Infer<typeof flags>;
export const logsCommand = Command.make("logs", flags).pipe(
Command.withDescription(
"Print recent logs from the local Supabase stack and optionally continue following live output.\n\n" +
"By default this prints the last 100 lines across all services, then keeps streaming new lines.\n\n" +
"Use --service to focus on one or more services, --tail 0 to skip backlog, and --no-follow to print a bounded snapshot and exit.",
),
Command.withShortDescription("Tail and follow local stack logs"),
Command.withExamples([
{
command: "supabase logs",
description: "Print recent logs across all services, then continue following live output",
},
{
command: "supabase logs --service postgres --no-follow",
description: "Print a recent Postgres-only snapshot and exit",
},
{
command: "supabase logs --service postgres --service auth --tail 20",
description: "Focus on a small recent backlog for two services, then follow live logs",
},
]),
Command.withHandler((flags) =>
logs(flags).pipe(withCommandInstrumentation(), withJsonErrorHandling),
),
Command.provide(commandRuntimeLayer(["logs"])),
);