diff --git a/package.json b/package.json index 635da60c..812a3361 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "@types/uuid": "^9.0.0", "c8": "^9.0.0", "codecov": "^3.5.0", - "gts": "^5.0.0", + "gts": "^6.0.0", "linkinator": "^4.0.0", "mocha": "^9.2.2", "post-install-check": "0.0.1", diff --git a/src/common.ts b/src/common.ts index d07c43f6..9fe28b02 100644 --- a/src/common.ts +++ b/src/common.ts @@ -145,7 +145,7 @@ export class LoggingCommon { { scopes: ['https://www.googleapis.com/auth/logging.write'], }, - options + options, ); this.logName = options.logName || 'winston_log'; @@ -168,7 +168,7 @@ export class LoggingCommon { this.cloudLog = new Logging(options).logSync( this.logName, undefined, - logSyncOptions + logSyncOptions, ); } this.resource = options.resource; @@ -182,7 +182,7 @@ export class LoggingCommon { level: string, message: string, metadata: MetadataArg | undefined, - callback: Callback + callback: Callback, ) { metadata = metadata || ({} as MetadataArg); // First create instrumentation record if it is never written before @@ -190,7 +190,7 @@ export class LoggingCommon { if (!setInstrumentationStatus(true)) { instrumentationEntry = createDiagnosticEntry( 'nodejs-winston', - getNodejsLibraryVersion() + getNodejsLibraryVersion(), ); // Update instrumentation record resource, logName and timestamp instrumentationEntry.metadata.resource = this.resource; @@ -305,7 +305,7 @@ export class LoggingCommon { // Make sure instrumentation entry is updated by underlying logger instrumentationEntry = this.entry( instrumentationEntry.metadata, - instrumentationEntry.data + instrumentationEntry.data, ); if (levelCode !== NPM_LEVEL_NAME_TO_CODE.info) { // We using info level for diagnostic records diff --git a/src/middleware/express.ts b/src/middleware/express.ts index b6ae61fa..5dfb1fbd 100644 --- a/src/middleware/express.ts +++ b/src/middleware/express.ts @@ -36,23 +36,23 @@ type Middleware = ReturnType; export async function makeMiddleware( logger: winston.Logger, transport: LoggingWinston, - skipParentEntryForCloudRun?: boolean + skipParentEntryForCloudRun?: boolean, ): Promise; export async function makeMiddleware( logger: winston.Logger, options?: Options, - skipParentEntryForCloudRun?: boolean + skipParentEntryForCloudRun?: boolean, ): Promise; export async function makeMiddleware( logger: winston.Logger, optionsOrTransport?: Options | LoggingWinston, - skipParentEntryForCloudRun?: boolean + skipParentEntryForCloudRun?: boolean, ): Promise { let transport: LoggingWinston; // If no custom transports are provided, use default or instantiate one. const cloudTransport = logger.transports.find( - t => t instanceof LoggingWinston + t => t instanceof LoggingWinston, ); // If user provides a custom transport, always add it to the logger. @@ -93,14 +93,14 @@ export async function makeMiddleware( ) { const requestLogName = Log.formatName_( projectId, - `${transport.common.logName}${REQUEST_LOG_SUFFIX}` + `${transport.common.logName}${REQUEST_LOG_SUFFIX}`, ); emitRequestLogEntry = ( httpRequest: HttpRequest, trace: string, span?: string, - sampled?: boolean + sampled?: boolean, ) => { logger.info({ // The request logs must have a log name distinct from the app logs @@ -119,6 +119,6 @@ export async function makeMiddleware( projectId, (trace: string, span?: string, sampled?: boolean) => makeChildLogger(logger, trace, span, sampled), - emitRequestLogEntry + emitRequestLogEntry, ); } diff --git a/src/middleware/make-child-logger.ts b/src/middleware/make-child-logger.ts index d517bc3b..3d96c273 100644 --- a/src/middleware/make-child-logger.ts +++ b/src/middleware/make-child-logger.ts @@ -23,7 +23,7 @@ export function makeChildLogger( logger: winston.Logger, trace: string, span?: string, - sampled?: boolean + sampled?: boolean, ) { return logger.child({ [LOGGING_TRACE_KEY]: trace, diff --git a/system-test/errors-transport.ts b/system-test/errors-transport.ts index c96a2f0a..d1a7971f 100644 --- a/system-test/errors-transport.ts +++ b/system-test/errors-transport.ts @@ -64,7 +64,7 @@ export class ErrorsApiTransport extends common.Service { async request(options: common.DecorateRequestOptions) { return new Promise((resolve, reject) => { super.request(options, (err, _, res) => - err ? reject(err) : resolve(res as common.ResponseBody) + err ? reject(err) : resolve(res as common.ResponseBody), ); }); } @@ -98,7 +98,7 @@ export class ErrorsApiTransport extends common.Service { async pollForNewEvents( service: string, time: number, - timeout: number + timeout: number, ): Promise { const timeLimit = Date.now() + timeout; let groupId; @@ -112,7 +112,7 @@ export class ErrorsApiTransport extends common.Service { // find an error group that matches the service groups.forEach(group => { const match = group.affectedServices.find( - context => context.service === service + context => context.service === service, ); if (match) { groupId = group.group.groupId; @@ -127,7 +127,7 @@ export class ErrorsApiTransport extends common.Service { const filteredEvents = events.filter( event => event.serviceContext.service === service && - new Date(event.eventTime).getTime() >= time + new Date(event.eventTime).getTime() >= time, ); if (filteredEvents.length) { return filteredEvents; diff --git a/system-test/logging-winston.ts b/system-test/logging-winston.ts index 02907904..0d5b02cb 100644 --- a/system-test/logging-winston.ts +++ b/system-test/logging-winston.ts @@ -101,7 +101,7 @@ describe('LoggingWinston', function () { entry.data as { message: string; } - ).message.startsWith('fourth Error:') + ).message.startsWith('fourth Error:'), ); }, }, @@ -120,7 +120,7 @@ describe('LoggingWinston', function () { entry.data as { message: string; } - ).message.startsWith('fifth message') + ).message.startsWith('fifth message'), ); }, }, @@ -143,7 +143,7 @@ describe('LoggingWinston', function () { LOG_NAME, start, testData.length, - WRITE_CONSISTENCY_DELAY_MS + WRITE_CONSISTENCY_DELAY_MS, ); assert.strictEqual(entries.length, testData.length); entries.reverse().forEach((entry, index) => { @@ -160,7 +160,7 @@ describe('LoggingWinston', function () { transports: [new LoggingWinston({logName: LOG_NAME})], format: winston.format.combine( winston.format.colorize(), - winston.format.padLevels() + winston.format.padLevels(), ), }); // Make sure we logging below with error severity so the further query @@ -171,14 +171,14 @@ describe('LoggingWinston', function () { LOG_NAME, start, 2, - WRITE_CONSISTENCY_DELAY_MS + WRITE_CONSISTENCY_DELAY_MS, ); entries.forEach(entry => { assert.ok(entry.data); if ( Object.prototype.hasOwnProperty.call( entry.data, - instrumentation.DIAGNOSTIC_INFO_KEY + instrumentation.DIAGNOSTIC_INFO_KEY, ) ) { const info = @@ -223,7 +223,7 @@ describe('LoggingWinston', function () { const errors = await errorsTransport.pollForNewEvents( service, start, - ERROR_REPORTING_POLL_TIMEOUT + ERROR_REPORTING_POLL_TIMEOUT, ); assert.strictEqual(errors.length, 1); @@ -241,7 +241,7 @@ function pollLogs( logName: string, logTime: number, size: number, - timeout: number + timeout: number, ) { const p = new Promise((resolve, reject) => { const end = Date.now() + timeout; @@ -269,7 +269,7 @@ function pollLogs( return reject(new Error('timeout')); } loop(); - } + }, ); }, 500); } diff --git a/system-test/test-middleware-express.ts b/system-test/test-middleware-express.ts index bfa33920..5c3f8a43 100644 --- a/system-test/test-middleware-express.ts +++ b/system-test/test-middleware-express.ts @@ -111,7 +111,7 @@ describe(__filename, () => { const [requestLogEntry] = requestLogEntries; assert.strictEqual( requestLogEntry.metadata.trace, - appLogEntry.metadata.trace + appLogEntry.metadata.trace, ); resolve(); diff --git a/test/common.ts b/test/common.ts index 7f2da073..39401702 100644 --- a/test/common.ts +++ b/test/common.ts @@ -116,7 +116,7 @@ describe('logging-common', () => { }); const loggingCommon = new loggingCommonLib.LoggingCommon( - optionsWithInspectMetadata + optionsWithInspectMetadata, ); assert.strictEqual(loggingCommon.inspectMetadata, true); }); @@ -130,7 +130,7 @@ describe('logging-common', () => { delete optionsWithoutLevels.levels; const loggingCommon = new loggingCommonLib.LoggingCommon( - optionsWithoutLevels + optionsWithoutLevels, ); assert.deepStrictEqual(loggingCommon.levels, { error: 3, @@ -150,7 +150,7 @@ describe('logging-common', () => { optionsWithLogName.logName = logName; const loggingCommon = new loggingCommonLib.LoggingCommon( - optionsWithLogName + optionsWithLogName, ); const loggingOptions = Object.assign({}, fakeLoggingOptions_); @@ -193,10 +193,10 @@ describe('logging-common', () => { { redirectToStdout: true, useMessageField: true, - } + }, ); const loggingCommon = new LoggingCommon( - optionsWithRedirectToStdoutAndUseMessage + optionsWithRedirectToStdoutAndUseMessage, ); assert.ok(loggingCommon.cloudLog instanceof LogSync); assert.ok(loggingCommon.cloudLog.useMessageField_ === true); @@ -230,7 +230,7 @@ describe('logging-common', () => { 'non-existent-level', MESSAGE, METADATA, - assert.ifError + assert.ifError, ); }, /Unknown log level: non-existent-level/); }); @@ -326,7 +326,7 @@ describe('logging-common', () => { { httpRequest: HTTP_REQUEST, }, - METADATA + METADATA, ); loggingCommon.cloudLog.entry = (entryMetadata: {}, data: {}) => { @@ -349,7 +349,7 @@ describe('logging-common', () => { { timestamp: date, }, - METADATA + METADATA, ); loggingCommon.cloudLog.entry = (entryMetadata: {}, data: {}) => { @@ -518,7 +518,7 @@ describe('logging-common', () => { loggingCommon.cloudLog[STACKDRIVER_LEVEL] = ( entry_: Entry[], - callback: () => void + callback: () => void, ) => { assert.deepEqual(entry_[0], entry); callback(); // done() @@ -533,14 +533,14 @@ describe('logging-common', () => { }; loggingCommon.cloudLog['info'] = ( entry_: Entry[], - callback: () => void + callback: () => void, ) => { assert.equal(entry_.length, 2); assert.equal( entry_[1].data[instrumentation.DIAGNOSTIC_INFO_KEY][ instrumentation.INSTRUMENTATION_SOURCE_KEY ][0].name, - 'nodejs-winston' + 'nodejs-winston', ); callback(); // done() }; @@ -558,7 +558,7 @@ describe('logging-common', () => { entry_[0].data[instrumentation.DIAGNOSTIC_INFO_KEY][ instrumentation.INSTRUMENTATION_SOURCE_KEY ][0].name, - 'nodejs-winston' + 'nodejs-winston', ); }; loggingCommon.cloudLog[STACKDRIVER_LEVEL] = (entry_: Entry[]) => { @@ -626,7 +626,7 @@ describe('logging-common', () => { LEVEL, MESSAGE, metadataWithoutLabels, - assert.ifError + assert.ifError, ); }; diff --git a/test/index.ts b/test/index.ts index dc1c2251..13412aa4 100644 --- a/test/index.ts +++ b/test/index.ts @@ -31,7 +31,7 @@ describe('logging-winston', () => { level: string, message: string, metadata: {} | undefined, - callback: () => void + callback: () => void, ): void { // eslint-disable-next-line prefer-rest-params lastFakeLoggingArgs = arguments; @@ -135,7 +135,7 @@ describe('logging-winston', () => { it('should pass the provided service context', () => { assert.strictEqual( fakeLoggingOptions_!.serviceContext, - OPTIONS.serviceContext + OPTIONS.serviceContext, ); }); @@ -150,7 +150,7 @@ describe('logging-winston', () => { handleRejections: false, }); new loggingWinstonLib.LoggingWinston( - optionsWithTransportStreamparameters + optionsWithTransportStreamparameters, ); assert.strictEqual(fakeLoggingOptions_!.level, level); assert.strictEqual(fakeLoggingOptions_!.format, format); diff --git a/test/middleware/express.ts b/test/middleware/express.ts index 1cefb195..40a18536 100644 --- a/test/middleware/express.ts +++ b/test/middleware/express.ts @@ -66,7 +66,7 @@ let passedEmitRequestLog: Function | undefined; function fakeMakeMiddleware( projectId: string, makeChildLogger: Function, - emitRequestLog: Function + emitRequestLog: Function, ): Function { passedProjectId = projectId; passedEmitRequestLog = emitRequestLog; @@ -104,7 +104,7 @@ describe('middleware/express', () => { assert.strictEqual( transport, t, - 'makeMiddleware should not construct a transport' + 'makeMiddleware should not construct a transport', ); });