Skip to content

Commit

Permalink
Fix log level parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalgn committed May 26, 2021
1 parent 1f4896c commit f77295e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 23 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,12 @@ For more information on when these occur, see the Github documentation on [event

To run the action with full debug logging, update your workflow file as follows:

```
```yaml
- name: automerge
uses: pascalgn/automerge-action@...
with:
args: "--trace"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
LOG: "TRACE" # or "DEBUG"
```

If you need to further debug the action, you can run it locally.
Expand Down
14 changes: 4 additions & 10 deletions bin/automerge.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ async function main() {
version: pkg.version,
help: "Show version number and exit"
});
parser.add_argument("-t", "--trace", {
action: "store_true",
help: "Show trace output"
});
parser.add_argument("-d", "--debug", {
action: "store_true",
help: "Show debugging output"
});
parser.add_argument("url", {
metavar: "<url>",
nargs: "?",
Expand All @@ -48,10 +40,12 @@ async function main() {

const args = parser.parse_args();

if (args.trace) {
if (process.env.LOG === "TRACE") {
logger.level = "trace";
} else if (args.debug) {
} else if (process.env.LOG === "DEBUG") {
logger.level = "debug";
} else if (process.env.LOG && process.env.LOG.length > 0) {
logger.error("Invalid log level:", process.env.LOG);
}

checkOldConfig();
Expand Down
14 changes: 4 additions & 10 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18281,14 +18281,6 @@ async function main() {
version: pkg.version,
help: "Show version number and exit"
});
parser.add_argument("-t", "--trace", {
action: "store_true",
help: "Show trace output"
});
parser.add_argument("-d", "--debug", {
action: "store_true",
help: "Show debugging output"
});
parser.add_argument("url", {
metavar: "<url>",
nargs: "?",
Expand All @@ -18297,10 +18289,12 @@ async function main() {

const args = parser.parse_args();

if (args.trace) {
if (process.env.LOG === "TRACE") {
logger.level = "trace";
} else if (args.debug) {
} else if (process.env.LOG === "DEBUG") {
logger.level = "debug";
} else if (process.env.LOG && process.env.LOG.length > 0) {
logger.error("Invalid log level:", process.env.LOG);
}

checkOldConfig();
Expand Down

0 comments on commit f77295e

Please sign in to comment.