Skip to content

Commit

Permalink
🐝 Add command debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
hyzyla committed Oct 19, 2024
1 parent 17c5577 commit cd63be8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
20 changes: 9 additions & 11 deletions src/common/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,16 @@ export async function exec(options: { command: string; args: string[]; cwd?: str
});
}

if (result.stdout && result.stderr) {
commonLogger.warn(`Both stdout and stderr are not empty for "${options.command}" command`, {
stdout: result.stdout,
stderr: result.stderr,
command: options.command,
args: options.args,
cwd: cwd,
});
return result.stdout;
}
commonLogger.debug("Command executed", {
command: options.command,
args: options.args,
cwd: cwd,
stdout: result.stdout,
stderr: result.stderr,
});

if (result.stderr) {
// check error code
if (result.stderr && !result.stdout) {
throw new ExecErrror(`Error executing "${options.command}" command`, {
stderr: result.stderr,
command: options.command,
Expand Down
2 changes: 1 addition & 1 deletion src/common/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class Logger {
}

error(message: string, context: Context & { error: unknown | null }) {
const stackTrace = context.error instanceof Error ? context.error.stack ?? "" : "";
const stackTrace = context.error instanceof Error ? (context.error.stack ?? "") : "";
this.addMessage({
message: message,
level: LogLevel.error,
Expand Down

0 comments on commit cd63be8

Please sign in to comment.