Skip to content

Commit

Permalink
fix(progress-logger): add info logLevel for ci-keep-alive messages
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio committed Dec 6, 2020
1 parent 6972614 commit ecacd30
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module.exports = {
/** Optional boolean flag used to set CI mode. process.env.CI is used when not set. */
CI: false,

/** Optional setting for log level. Valid values are verbose, warn, error. Defaults to verbose. */
/** Optional setting for log level. Valid values are verbose, info, warn, error. Defaults to verbose. */
logLevel: 'verbose',

/** Optional boolean flag used to enable caching of cloned repositories. For CIs it's ideal to disable caching. Defauls to true. */
Expand Down
2 changes: 1 addition & 1 deletion lib/config/config-templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const CONFIGURATION_FILE_TEMPLATE =
/** Optional boolean flag used to set CI mode. process.env.CI is used when not set. */
CI: false,
/** Optional setting for log level. Valid values are verbose, warn, error. Defaults to verbose. */
/** Optional setting for log level. Valid values are verbose, info, warn, error. Defaults to verbose. */
logLevel: 'verbose',
/** Optional boolean flag used to enable caching of cloned repositories. For CIs it's ideal to disable caching. Defauls to true. */
Expand Down
2 changes: 1 addition & 1 deletion lib/config/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ResultTemplateOptions } from '@file-client/result-templates';
export const ResultParsers: ['plaintext', 'markdown'];
export type ResultParser = typeof ResultParsers[number];

export const LogLevels: ['verbose', 'warn', 'error'];
export const LogLevels: ['verbose', 'info', 'warn', 'error'];
export type LogLevel = typeof LogLevels[number];

/** Contents of the `eslint-remote-tester.config.js` */
Expand Down
2 changes: 1 addition & 1 deletion lib/config/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from './types';

const RESULT_PARSERS: typeof ResultParsers = ['plaintext', 'markdown'];
const LOG_LEVELS: typeof LogLevels = ['verbose', 'warn', 'error'];
const LOG_LEVELS: typeof LogLevels = ['verbose', 'info', 'warn', 'error'];

const DEFAULT_RESULT_PARSER_CLI: ResultParser = 'markdown';
const DEFAULT_RESULT_PARSER_CI: ResultParser = 'plaintext';
Expand Down
16 changes: 10 additions & 6 deletions lib/progress-logger/progress-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ function isLogVisible(log: LogMessage): boolean {
case 'verbose':
return true;

case 'info':
return ['info', 'warn', 'error'].includes(log.level);

case 'warn':
return ['warn', 'error'].includes(log.level);

Expand Down Expand Up @@ -397,13 +400,14 @@ class ProgressLogger {
* - These are used to avoid CI timeouts
*/
onCiStatus() {
const message = Templates.CI_STATUS_TEMPLATE(
this.scannedRepositories,
this.tasks
);
if (['verbose', 'info'].includes(config.logLevel)) {
const message = Templates.CI_STATUS_TEMPLATE(
this.scannedRepositories,
this.tasks
);

// Note that these are never excluded from CI - no matter what `config.logLevel` value is
this.listeners.ciKeepAlive.forEach(listener => listener(message));
this.listeners.ciKeepAlive.forEach(listener => listener(message));
}
}
}

Expand Down

0 comments on commit ecacd30

Please sign in to comment.