Skip to content

Commit

Permalink
feat(logs): implement several filters & support retrieval of persiste…
Browse files Browse the repository at this point in the history
…d logs (#165)

This commit does two enhancements to the `log` subcommand.

- add several options such as `--grep`, `--levels`, and `--regions` that allows for filtering out logs that we're not interested in
- add options called `--since` and `--until`, which enable the retrieval of persisted logs (as opposed to live logs)
  • Loading branch information
magurotuna authored Jul 27, 2023
1 parent 696ad05 commit e9f695b
Show file tree
Hide file tree
Showing 8 changed files with 470 additions and 91 deletions.
7 changes: 7 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 4 additions & 27 deletions deployctl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

// Copyright 2021 Deno Land Inc. All rights reserved. MIT license.

import { parseArgs, semverGreaterThanOrEquals } from "./deps.ts";
import { semverGreaterThanOrEquals } from "./deps.ts";
import { parseArgs } from "./src/args.ts";
import { error } from "./src/error.ts";
import deploySubcommand from "./src/subcommands/deploy.ts";
import upgradeSubcommand from "./src/subcommands/upgrade.ts";
Expand All @@ -22,7 +23,7 @@ To deploy a remote script:
SUBCOMMANDS:
deploy Deploy a script with static files to Deno Deploy
upgrade Upgrade deployctl to the given version (defaults to latest)
logs Stream logs for the given project
logs View logs for the given project
`;

if (!semverGreaterThanOrEquals(Deno.version.deno, MINIMUM_DENO_VERSION)) {
Expand All @@ -31,31 +32,7 @@ if (!semverGreaterThanOrEquals(Deno.version.deno, MINIMUM_DENO_VERSION)) {
);
}

const args = parseArgs(Deno.args, {
alias: {
"help": "h",
"version": "V",
"project": "p",
},
boolean: [
"help",
"prod",
"static",
"version",
"dry-run",
],
string: [
"project",
"token",
"include",
"exclude",
"import-map",
"deployment",
],
default: {
static: true,
},
});
const args = parseArgs(Deno.args);

if (Deno.isatty(Deno.stdin.rid)) {
let latestVersion;
Expand Down
2 changes: 1 addition & 1 deletion deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export {
red,
yellow,
} from "https://deno.land/[email protected]/fmt/colors.ts";
export { parse as parseArgs } from "https://deno.land/std@0.170.0/flags/mod.ts";
export { parse } from "https://deno.land/std@0.195.0/flags/mod.ts";
export { TextLineStream } from "https://deno.land/[email protected]/streams/text_line_stream.ts";

// x/semver
Expand Down
42 changes: 42 additions & 0 deletions src/args.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2021 Deno Land Inc. All rights reserved. MIT license.

import { parse } from "../deps.ts";

export function parseArgs(args: string[]) {
const parsed = parse(args, {
alias: {
"help": "h",
"version": "V",
"project": "p",
},
boolean: [
"help",
"prod",
"static",
"version",
"dry-run",
],
string: [
"project",
"token",
"include",
"exclude",
"import-map",
"deployment",
"since",
"until",
"grep",
"levels",
"regions",
"limit",
],
collect: ["grep"],
default: {
static: true,
limit: "100",
},
});
return parsed;
}

export type Args = ReturnType<typeof parseArgs>;
Loading

0 comments on commit e9f695b

Please sign in to comment.