Skip to content

Commit

Permalink
improvement(cli): output error details to console with log level 5
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald committed Feb 19, 2020
1 parent d0698b4 commit 0c69b6e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 8 additions & 3 deletions garden-service/src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import stringify = require("json-stringify-safe")
import { generateBasicDebugInfoReport } from "../commands/get/get-debug-info"
import { AnalyticsHandler } from "../analytics/analytics"
import { defaultDotIgnoreFiles } from "../util/fs"
import { renderError } from "../logger/renderers"

const OUTPUT_RENDERERS = {
json: (data: DeepPrimitiveMap) => {
Expand Down Expand Up @@ -449,12 +450,16 @@ export class GardenCli {
}

if (gardenErrors.length > 0) {
gardenErrors.forEach((error) =>
logger.error({
for (const error of gardenErrors) {
const entry = logger.error({
msg: error.message,
error,
})
)
// Output error details to console when log level is silly
logger.silly({
msg: renderError(entry),
})
}

if (logger.writers.find((w) => w instanceof FileWriter)) {
logger.info(`\nSee ${ERROR_LOG_FILENAME} for detailed error message`)
Expand Down
4 changes: 3 additions & 1 deletion garden-service/src/task-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { Garden } from "./garden"
import { dedent } from "./util/string"
import uuid from "uuid"
import { defer, relationshipClasses } from "./util/util"
import { renderError } from "./logger/renderers"

class TaskGraphError extends GardenBaseError {
type = "task-graph"
Expand Down Expand Up @@ -532,7 +533,8 @@ export class TaskGraph {
(hasAnsi(errorMessage) ? errorMessage : chalk.red(errorMessage)) +
chalk.red.bold(`\n${divider}\n`)

this.log.error({ msg, error })
const entry = this.log.error({ msg, error })
this.log.silly({ msg: renderError(entry) })
}
}

Expand Down

0 comments on commit 0c69b6e

Please sign in to comment.