Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(cli): add output for waiting logs #3066

Merged
merged 5 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/cli/src/lib/run/log-displayer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {APIClient} from '@heroku-cli/command'
import {ux} from '@oclif/core'
import color from '@heroku-cli/color'
import colorize from './colorize'
import {isFirApp} from '../apps/generation'
import {LogSession} from '../types/fir'
Expand Down Expand Up @@ -74,17 +75,19 @@ async function logDisplayer(heroku: APIClient, options: LogDisplayerOptions) {
source: options.source,
}

if (firApp)
if (firApp) {
process.stderr.write(color.cyan.bold('Fetching logs...\n\n'))
Object.assign(requestBodyParameters, {
dyno: options.dyno,
type: options.type,
})
else
} else {
Object.assign(requestBodyParameters, {
dyno: options.dyno || options.type,
lines: options.lines,
tail: options.tail,
})
}

let recreateLogSession = false
do {
Expand Down
7 changes: 6 additions & 1 deletion packages/cli/test/unit/lib/run/log-displayer.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {Config} from '@oclif/core'
import {CLIError} from '@oclif/core/lib/errors'
import {expect} from 'chai'
import * as nock from 'nock'
import {stdout} from 'stdout-stderr'
import {stdout, stderr} from 'stdout-stderr'
import heredoc from 'tsheredoc'
import logDisplayer from '../../../../src/lib/run/log-displayer'
import {cedarApp, firApp} from '../../../fixtures/apps/fixtures'
Expand Down Expand Up @@ -380,12 +380,14 @@ describe('logDisplayer', function () {

try {
stdout.start()
stderr.start()
await logDisplayer(heroku, {
app: 'my-fir-app',
tail: false,
})
} catch (error: unknown) {
stdout.stop()
stderr.stop()
const {message} = error as Error
expect(message.trim()).to.equal('HTTP Error 500 for POST https://api.heroku.com/apps/my-fir-app/log-sessions')
}
Expand All @@ -403,6 +405,9 @@ describe('logDisplayer', function () {

logSession1.done()
logSession2.done()

// it displays message about fetching logs for fir apps
expect(stderr.output).to.eq('Fetching logs...\n\n')
})
})
})
Loading