Comparing version 3.1.0 to 3.1.1
@@ -47,3 +47,3 @@ "use strict"; | ||
this.presets = Object.assign({ module: moduleName }, ((0, utils_1.isObject)(presets) ? presets : {})); | ||
this.loggerServices = (loggerServices || ['loggly']).map(utils_1.getLoggerService); | ||
this.loggerServices = (loggerServices || [{ type: 'loggly' }]).map(utils_1.getLoggerService); | ||
if (addTrackId && !this.presets.trackId) { | ||
@@ -50,0 +50,0 @@ this.presets.trackId = (0, crypto_1.randomUUID)(); |
@@ -11,11 +11,20 @@ import { Request, Response } from 'express'; | ||
} | ||
declare const loggerServices: readonly ["loggly", "gcp"]; | ||
export type LoggerService = typeof loggerServices[number]; | ||
export interface GcpLoggerService { | ||
email: string; | ||
key: string; | ||
projectId: string; | ||
type: 'gcp'; | ||
} | ||
export interface LogglyLoggerService { | ||
logglyToken?: string; | ||
type: 'loggly'; | ||
} | ||
export type LoggerService = GcpLoggerService | LogglyLoggerService; | ||
export interface LaLogOptions { | ||
addTrackId?: boolean; | ||
isTransient?: boolean; | ||
loggerServices?: LoggerService[]; | ||
moduleName?: string; | ||
presets?: LogPresets; | ||
serviceName?: string; | ||
isTransient?: boolean; | ||
loggerServices?: LoggerService[]; | ||
} | ||
@@ -51,2 +60,1 @@ export type ParseReqIn = Request & { | ||
}; | ||
export {}; |
@@ -5,3 +5,2 @@ "use strict"; | ||
exports.levels = ['trace', 'info', 'warn', 'error', 'fatal', 'security']; | ||
const loggerServices = ['loggly', 'gcp']; | ||
//# sourceMappingURL=local-types.js.map |
import { LogBatch, LogSingle } from '../utils'; | ||
export declare const logSingle: LogSingle; | ||
export declare const logBatch: LogBatch; | ||
export declare const logglyLoggers: { | ||
import { LogglyLoggerService } from '../local-types'; | ||
export declare const logglyLoggers: (serviceCredentials: LogglyLoggerService) => { | ||
logBatch: LogBatch; | ||
logSingle: LogSingle; | ||
}; |
@@ -6,7 +6,10 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.logglyLoggers = exports.logBatch = exports.logSingle = void 0; | ||
exports.logglyLoggers = void 0; | ||
const node_fetch_1 = __importDefault(require("node-fetch")); | ||
const utils_1 = require("../utils"); | ||
const log = async (options, bulk) => { | ||
const { tag, logglyToken = process.env.LOGGLY_TOKEN, logObj: body, } = options; | ||
const { tag, logObj: body, } = options; | ||
const logglyToken = options.serviceCredentials.logglyToken | ||
|| options.logglyToken | ||
|| process.env.LOGGLY_TOKEN; | ||
const pathPart = bulk ? 'bulk' : 'inputs'; | ||
@@ -51,3 +54,3 @@ if (logglyToken) { | ||
}; | ||
const logSingle = (options) => { | ||
const logSingleSetup = (serviceCredentials) => async (options) => { | ||
const { logObj } = options; | ||
@@ -60,6 +63,5 @@ if (!(0, utils_1.isObject)(logObj)) { | ||
const body = (0, utils_1.safeJsonStringify)(logObj); | ||
return log(Object.assign(Object.assign({}, options), { logObj: body }), false); | ||
return log(Object.assign(Object.assign({}, options), { logObj: body, serviceCredentials }), false); | ||
}; | ||
exports.logSingle = logSingle; | ||
const logBatch = async (options) => { | ||
const logBatchSetup = (serviceCredentials) => async (options) => { | ||
const { logObj } = options; | ||
@@ -72,9 +74,9 @@ if (!Array.isArray(logObj)) { | ||
const body = logObj.map((logEntry) => (0, utils_1.safeJsonStringify)(logEntry)).join('\n'); | ||
return log(Object.assign(Object.assign({}, options), { logObj: body }), true); | ||
return log(Object.assign(Object.assign({}, options), { logObj: body, serviceCredentials }), true); | ||
}; | ||
exports.logBatch = logBatch; | ||
exports.logglyLoggers = { | ||
logBatch: exports.logBatch, | ||
logSingle: exports.logSingle, | ||
}; | ||
const logglyLoggers = (serviceCredentials) => ({ | ||
logBatch: logBatchSetup(serviceCredentials), | ||
logSingle: logSingleSetup(serviceCredentials), | ||
}); | ||
exports.logglyLoggers = logglyLoggers; | ||
//# sourceMappingURL=loggly-wrapper.js.map |
@@ -5,3 +5,3 @@ "use strict"; | ||
const loggly_wrapper_1 = require("./loggly/loggly-wrapper"); | ||
const gcp_wrapper_copy_1 = require("./gcp/gcp-wrapper-copy"); | ||
const gcp_wrapper_1 = require("./gcp/gcp-wrapper"); | ||
const isObject = (obj) => !!obj && obj.toString() === '[object Object]' && !Array.isArray(obj); | ||
@@ -56,7 +56,7 @@ exports.isObject = isObject; | ||
const getLoggerService = (loggerService) => { | ||
switch (loggerService) { | ||
switch (loggerService.type) { | ||
case 'gcp': | ||
return gcp_wrapper_copy_1.gcpLoggers; | ||
return (0, gcp_wrapper_1.gcpLoggers)(loggerService); | ||
case 'loggly': | ||
return loggly_wrapper_1.logglyLoggers; | ||
return (0, loggly_wrapper_1.logglyLoggers)(loggerService); | ||
default: | ||
@@ -63,0 +63,0 @@ throw new Error('invalid logger service'); |
@@ -57,3 +57,3 @@ { | ||
"types": "dist/index.d.ts", | ||
"version": "3.1.0" | ||
"version": "3.1.1" | ||
} |
@@ -18,4 +18,3 @@ { | ||
"include": [ | ||
"lib/**/*", | ||
"gcp-testing/gcp-tester.ts" | ||
"lib/**/*" | ||
], | ||
@@ -22,0 +21,0 @@ "exclude": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
3
385083
43
1428