diff --git a/lib/logging.js b/lib/logging.js index 0523b0be..fb598c5d 100644 --- a/lib/logging.js +++ b/lib/logging.js @@ -9,7 +9,7 @@ import getEntityName from './get-entity-name' export const logEmitter = new EventEmitter() -function extractErrorInformation(error) { +function extractErrorInformation (error) { const source = error.originalError || error try { const data = JSON.parse(source.message) @@ -21,7 +21,7 @@ function extractErrorInformation(error) { } } -export function formatLogMessageOneLine(logMessage) { +export function formatLogMessageOneLine (logMessage) { const { level } = logMessage if (!level) { return logMessage.toString().replace(/\s+/g, ' ') @@ -62,7 +62,7 @@ export function formatLogMessageOneLine(logMessage) { } } -export function formatLogMessagelogFileWriteStream(logMessage) { +export function formatLogMessagelogFileWriteStream (logMessage) { const { level } = logMessage if (level === 'info' || level === 'warning') { return logMessage @@ -96,14 +96,11 @@ export function formatLogMessagelogFileWriteStream(logMessage) { } // Display all errors -export function displayErrorLog(errorLog) { +export function displayErrorLog (errorLog) { if (errorLog.length) { const count = errorLog.reduce( (count, curr) => { - if (Object.prototype.hasOwnProperty.call(curr, 'warning')) - count.warnings++ - else if (Object.prototype.hasOwnProperty.call(curr, 'error')) - count.errors++ + if (Object.prototype.hasOwnProperty.call(curr, 'warning')) { count.warnings++ } else if (Object.prototype.hasOwnProperty.call(curr, 'error')) { count.errors++ } return count }, { warnings: 0, errors: 0 } @@ -134,7 +131,7 @@ export function displayErrorLog(errorLog) { * @param {Record[]} errorLog * @returns {Promise} */ -export async function writeErrorLogFile(destination, errorLog) { +export async function writeErrorLogFile (destination, errorLog) { const formatLogTransformer = new Transform({ objectMode: true, transform: (chunk, encoding, callback) => { @@ -165,8 +162,8 @@ export async function writeErrorLogFile(destination, errorLog) { * @param {Record[]} log * @returns {Promise} */ -export function setupLogging(log) { - function errorLogger(level, error) { +export function setupLogging (log) { + function errorLogger (level, error) { const logMessage = { ts: new Date().toJSON(), level, @@ -188,8 +185,8 @@ export function setupLogging(log) { * @template {Ctx} * @param {import('listr').ListrTaskWrapper} task */ -export function logToTaskOutput(task) { - function logToTask(logMessage) { +export function logToTaskOutput (task) { + function logToTask (logMessage) { const content = formatLogMessageOneLine(logMessage) const symbols = { info: figures.tick, diff --git a/test/logging.test.js b/test/logging.test.js index 15097f52..da1e0673 100644 --- a/test/logging.test.js +++ b/test/logging.test.js @@ -11,7 +11,7 @@ import { } from '../lib/logging' import figures from 'figures' -function isValidDate(date) { +function isValidDate (date) { return !isNaN(Date.parse(date)) } @@ -207,7 +207,7 @@ test('sets up logging via event emitter', () => { expect(logEmitterAddListenerSpy.mock.calls[1][0]).toBe('warning') expect(logEmitterAddListenerSpy.mock.calls[2][0]).toBe('error') - function assertLogValues(logMessage) { + function assertLogValues (logMessage) { if (logMessage.level === 'info') { // Info messages are not logged return