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(deps): update dependency gts to v6 - abandoned #858

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class LoggingCommon {
{
scopes: ['https://www.googleapis.com/auth/logging.write'],
},
options
options,
);

this.logName = options.logName || 'winston_log';
Expand All @@ -168,7 +168,7 @@ export class LoggingCommon {
this.cloudLog = new Logging(options).logSync(
this.logName,
undefined,
logSyncOptions
logSyncOptions,
);
}
this.resource = options.resource;
Expand All @@ -182,15 +182,15 @@ 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
let instrumentationEntry: Entry | undefined;
if (!setInstrumentationStatus(true)) {
instrumentationEntry = createDiagnosticEntry(
'nodejs-winston',
getNodejsLibraryVersion()
getNodejsLibraryVersion(),
);
// Update instrumentation record resource, logName and timestamp
instrumentationEntry.metadata.resource = this.resource;
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions src/middleware/express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,23 @@ type Middleware = ReturnType<typeof commonMiddleware.express.makeMiddleware>;
export async function makeMiddleware(
logger: winston.Logger,
transport: LoggingWinston,
skipParentEntryForCloudRun?: boolean
skipParentEntryForCloudRun?: boolean,
): Promise<Middleware>;
export async function makeMiddleware(
logger: winston.Logger,
options?: Options,
skipParentEntryForCloudRun?: boolean
skipParentEntryForCloudRun?: boolean,
): Promise<Middleware>;
export async function makeMiddleware(
logger: winston.Logger,
optionsOrTransport?: Options | LoggingWinston,
skipParentEntryForCloudRun?: boolean
skipParentEntryForCloudRun?: boolean,
): Promise<Middleware> {
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.
Expand Down Expand Up @@ -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
Expand All @@ -119,6 +119,6 @@ export async function makeMiddleware(
projectId,
(trace: string, span?: string, sampled?: boolean) =>
makeChildLogger(logger, trace, span, sampled),
emitRequestLogEntry
emitRequestLogEntry,
);
}
2 changes: 1 addition & 1 deletion src/middleware/make-child-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions system-test/errors-transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class ErrorsApiTransport extends common.Service {
async request(options: common.DecorateRequestOptions) {
return new Promise<ApiResponse>((resolve, reject) => {
super.request(options, (err, _, res) =>
err ? reject(err) : resolve(res as common.ResponseBody)
err ? reject(err) : resolve(res as common.ResponseBody),
);
});
}
Expand Down Expand Up @@ -98,7 +98,7 @@ export class ErrorsApiTransport extends common.Service {
async pollForNewEvents(
service: string,
time: number,
timeout: number
timeout: number,
): Promise<ErrorEvent[]> {
const timeLimit = Date.now() + timeout;
let groupId;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
18 changes: 9 additions & 9 deletions system-test/logging-winston.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe('LoggingWinston', function () {
entry.data as {
message: string;
}
).message.startsWith('fourth Error:')
).message.startsWith('fourth Error:'),
);
},
},
Expand All @@ -120,7 +120,7 @@ describe('LoggingWinston', function () {
entry.data as {
message: string;
}
).message.startsWith('fifth message')
).message.startsWith('fifth message'),
);
},
},
Expand All @@ -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) => {
Expand All @@ -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
Expand All @@ -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 =
Expand Down Expand Up @@ -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);
Expand All @@ -241,7 +241,7 @@ function pollLogs(
logName: string,
logTime: number,
size: number,
timeout: number
timeout: number,
) {
const p = new Promise<Entry[]>((resolve, reject) => {
const end = Date.now() + timeout;
Expand Down Expand Up @@ -269,7 +269,7 @@ function pollLogs(
return reject(new Error('timeout'));
}
loop();
}
},
);
}, 500);
}
Expand Down
2 changes: 1 addition & 1 deletion system-test/test-middleware-express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe(__filename, () => {
const [requestLogEntry] = requestLogEntries;
assert.strictEqual(
requestLogEntry.metadata.trace,
appLogEntry.metadata.trace
appLogEntry.metadata.trace,
);

resolve();
Expand Down
26 changes: 13 additions & 13 deletions test/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe('logging-common', () => {
});

const loggingCommon = new loggingCommonLib.LoggingCommon(
optionsWithInspectMetadata
optionsWithInspectMetadata,
);
assert.strictEqual(loggingCommon.inspectMetadata, true);
});
Expand All @@ -130,7 +130,7 @@ describe('logging-common', () => {
delete optionsWithoutLevels.levels;

const loggingCommon = new loggingCommonLib.LoggingCommon(
optionsWithoutLevels
optionsWithoutLevels,
);
assert.deepStrictEqual(loggingCommon.levels, {
error: 3,
Expand All @@ -150,7 +150,7 @@ describe('logging-common', () => {
optionsWithLogName.logName = logName;

const loggingCommon = new loggingCommonLib.LoggingCommon(
optionsWithLogName
optionsWithLogName,
);

const loggingOptions = Object.assign({}, fakeLoggingOptions_);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -230,7 +230,7 @@ describe('logging-common', () => {
'non-existent-level',
MESSAGE,
METADATA,
assert.ifError
assert.ifError,
);
}, /Unknown log level: non-existent-level/);
});
Expand Down Expand Up @@ -326,7 +326,7 @@ describe('logging-common', () => {
{
httpRequest: HTTP_REQUEST,
},
METADATA
METADATA,
);

loggingCommon.cloudLog.entry = (entryMetadata: {}, data: {}) => {
Expand All @@ -349,7 +349,7 @@ describe('logging-common', () => {
{
timestamp: date,
},
METADATA
METADATA,
);

loggingCommon.cloudLog.entry = (entryMetadata: {}, data: {}) => {
Expand Down Expand Up @@ -518,7 +518,7 @@ describe('logging-common', () => {

loggingCommon.cloudLog[STACKDRIVER_LEVEL] = (
entry_: Entry[],
callback: () => void
callback: () => void,
) => {
assert.deepEqual(entry_[0], entry);
callback(); // done()
Expand All @@ -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()
};
Expand All @@ -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[]) => {
Expand Down Expand Up @@ -626,7 +626,7 @@ describe('logging-common', () => {
LEVEL,
MESSAGE,
metadataWithoutLabels,
assert.ifError
assert.ifError,
);
};

Expand Down
6 changes: 3 additions & 3 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -135,7 +135,7 @@ describe('logging-winston', () => {
it('should pass the provided service context', () => {
assert.strictEqual(
fakeLoggingOptions_!.serviceContext,
OPTIONS.serviceContext
OPTIONS.serviceContext,
);
});

Expand All @@ -150,7 +150,7 @@ describe('logging-winston', () => {
handleRejections: false,
});
new loggingWinstonLib.LoggingWinston(
optionsWithTransportStreamparameters
optionsWithTransportStreamparameters,
);
assert.strictEqual(fakeLoggingOptions_!.level, level);
assert.strictEqual(fakeLoggingOptions_!.format, format);
Expand Down
4 changes: 2 additions & 2 deletions test/middleware/express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ let passedEmitRequestLog: Function | undefined;
function fakeMakeMiddleware(
projectId: string,
makeChildLogger: Function,
emitRequestLog: Function
emitRequestLog: Function,
): Function {
passedProjectId = projectId;
passedEmitRequestLog = emitRequestLog;
Expand Down Expand Up @@ -104,7 +104,7 @@ describe('middleware/express', () => {
assert.strictEqual(
transport,
t,
'makeMiddleware should not construct a transport'
'makeMiddleware should not construct a transport',
);
});

Expand Down