Skip to content

Commit

Permalink
improvement(logger): some minor fixes
Browse files Browse the repository at this point in the history
Particularly:
- Setting logs for some built-in providers to debug because that's just
  more fitting
- Use the "correct" log context when rendering new lines for graph and
  provider logs. If we use this.log the newlines are visible in the dev
  console where they shouldn't be because that's in the context of
  "internal" commands
  • Loading branch information
eysi09 committed Nov 23, 2023
1 parent 34b07fe commit 2120f9b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion core/src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,10 @@ ${renderCommands(commands)}
// Init Cloud API (if applicable)
let cloudApi: CloudApi | undefined

gardenLog.info("Initializing...")
if (!command.isDevCommand) {
// Print a Garden log before the Cloud logs, just for setting context (skipped in dev console)
gardenLog.info("Initializing...")
}
if (!command.noProject) {
const config = await this.getProjectConfig(log, workingDir)
const cloudDomain = getGardenCloudDomain(config?.domain)
Expand Down
4 changes: 2 additions & 2 deletions core/src/commands/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class LoginCommand extends Command<{}, Opts> {
const cloudApi = await CloudApi.factory({ log, cloudDomain, skipLogging: true, globalConfigStore })

if (cloudApi) {
log.info({ msg: `You're already logged in to ${cloudDomain}.` })
log.success({ msg: `You're already logged in to ${cloudDomain}.` })
cloudApi.close()
return {}
}
Expand All @@ -114,7 +114,7 @@ export class LoginCommand extends Command<{}, Opts> {
log.info({ msg: `Logging in to ${cloudDomain}...` })
const tokenResponse = await login(log, cloudDomain, garden.events)
await CloudApi.saveAuthToken(log, globalConfigStore, tokenResponse, cloudDomain)
log.info({ msg: `Successfully logged in to ${cloudDomain}.` })
log.success({ msg: `Successfully logged in to ${cloudDomain}.`, showDuration: false })

return {}
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/garden.ts
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ export class Garden {
providerLog.silly(() => `Resolved providers: ${providers.map((p) => p.name).join(", ")}`)

// Print a new line after resolving providers
this.log.info("")
providerLog.info("")
})

return keyBy(providers, "name")
Expand Down Expand Up @@ -1164,7 +1164,7 @@ export class Garden {

graphLog.success("Done")
// Print a new line after resolving graph
this.log.info("")
graphLog.info("")

return graph.toConfigGraph()
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/tasks/resolve-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ import type { Log } from "../logger/log-entry.js"
* resolved per se. A bit hacky but this is just a cosmetic change.
*/
function getProviderLog(providerName: string, log: Log) {
const verboseLogProviders = ["templated", "container"]
const fixLevel = verboseLogProviders.includes(providerName) ? LogLevel.verbose : undefined
const debugLogProviders = ["templated", "container"]
const fixLevel = debugLogProviders.includes(providerName) ? LogLevel.silly : undefined
return log.createLog({ name: providerName, fixLevel })
}

Expand Down

0 comments on commit 2120f9b

Please sign in to comment.