1 | 'use strict'
|
2 |
|
3 | let cli = require('heroku-cli-util')
|
4 | let logDisplayer = require('../lib/log_displayer')
|
5 | const { DynoCompletion, ProcessTypeCompletion } = require('@heroku-cli/command/lib/completions')
|
6 |
|
7 | async function run (context, heroku) {
|
8 | cli.color.enabled = context.flags['force-colors'] || cli.color.enabled
|
9 | await logDisplayer(heroku, {
|
10 | app: context.app,
|
11 | dyno: context.flags.dyno || context.flags.ps,
|
12 | lines: context.flags.num || 100,
|
13 | tail: context.flags.tail,
|
14 | source: context.flags.source
|
15 | })
|
16 | }
|
17 |
|
18 | module.exports = {
|
19 | topic: 'logs',
|
20 | description: `display recent log output
|
21 | disable colors with --no-color, HEROKU_LOGS_COLOR=0, or HEROKU_COLOR=0`,
|
22 | examples: `$ heroku logs
|
23 | 2012-01-01T12:00:00+00:00 heroku[api]: Config add EXAMPLE by email@example.com
|
24 | 2012-01-01T12:00:01+00:00 heroku[api]: Release v1 created by email@example.com`,
|
25 | needsAuth: true,
|
26 | needsApp: true,
|
27 | flags: [
|
28 | { name: 'num', char: 'n', description: 'number of lines to display', hasValue: true },
|
29 | { name: 'ps', char: 'p', description: 'hidden alias for dyno', hasValue: true, hidden: true },
|
30 | { name: 'dyno', char: 'd', description: 'only show output from this dyno type (such as "web" or "worker")', hasValue: true, completion: DynoCompletion },
|
31 | { name: 'source', char: 's', description: 'only show output from this source (such as "app" or "heroku")', hasValue: true, completion: ProcessTypeCompletion },
|
32 | { name: 'tail', char: 't', description: 'continually stream logs' },
|
33 | { name: 'force-colors', description: 'force use of colors (even on non-tty output)' }
|
34 | ],
|
35 | run: cli.command(run)
|
36 | }
|