Skip to content

Commit

Permalink
refactor(logger): rename preserveLevel opt to childEntriesInheritLevel
Browse files Browse the repository at this point in the history
Really it should just be `bequeathLevel`.
  • Loading branch information
eysi09 committed Jan 31, 2019
1 parent 5b11322 commit 0b3efab
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion garden-service/src/commands/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class LogsCommand extends Command<Args, Opts> {
})

await Bluebird.map(services, async (service: Service<any>) => {
const voidLog = log.placeholder(LogLevel.silly, { preserveLevel: true })
const voidLog = log.placeholder(LogLevel.silly, { childEntriesInheritLevel: true })
const status = await garden.actions.getServiceStatus({ log: voidLog, service, hotReload: false })

if (status.state === "ready" || status.state === "outdated") {
Expand Down
6 changes: 3 additions & 3 deletions garden-service/src/logger/log-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface UpdateOpts {
error?: GardenError
status?: EntryStatus
indent?: number
preserveLevel?: boolean
childEntriesInheritLevel?: boolean
}

export interface CreateOpts extends UpdateOpts {
Expand Down Expand Up @@ -110,9 +110,9 @@ export class LogEntry extends LogNode {
...resolveParam(param),
}

// If preserveLevel is set to true, all children must have a level geq the level
// If childEntriesInheritLevel is set to true, all children must have a level geq the level
// of the parent entry that set the flag.
const parentWithPreserveFlag = findParentEntry(this, entry => !!entry.opts.preserveLevel)
const parentWithPreserveFlag = findParentEntry(this, entry => !!entry.opts.childEntriesInheritLevel)
const childLevel = parentWithPreserveFlag ? Math.max(parentWithPreserveFlag.level, level) : level

return new LogEntry({
Expand Down
2 changes: 1 addition & 1 deletion garden-service/src/server/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export async function resolveRequest(
const cmdGarden = await Garden.factory(garden.projectRoot, garden.opts)

// We generally don't want actions to log anything in the server.
const cmdLog = log.placeholder(LogLevel.silly, { preserveLevel: true })
const cmdLog = log.placeholder(LogLevel.silly, { childEntriesInheritLevel: true })

const cmdArgs = mapParams(ctx, request.parameters, command.arguments)
const cmdOpts = mapParams(ctx, request.parameters, command.options)
Expand Down
4 changes: 2 additions & 2 deletions garden-service/test/logger/log-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ describe("LogEntry", () => {
]
expect(indents).to.eql([undefined, 1, 2, 3, 2, 3])
})
context("preserveLevel is set to true", () => {
context("childEntriesInheritLevel is set to true", () => {
it("should create a log entry whose children inherit the parent level", () => {
const verbose = logger.verbose({ preserveLevel: true })
const verbose = logger.verbose({ childEntriesInheritLevel: true })
const error = verbose.error("")
const silly = verbose.silly("")
const deepError = error.error("")
Expand Down

0 comments on commit 0b3efab

Please sign in to comment.