@shellicar/winston-azure-application-insights 6.0.0 → 6.0.2-preview.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("winston-transport"),t=require("triple-beam"),r=require("applicationinsightsv3"),n=require("winston"),o=require("process");function i(e){return e&&e.__esModule?e:{default:e}}var s=i(e),l=i(n),a=Object.defineProperty,c=(e,t)=>a(e,"name",{value:t,configurable:!0}),p=(e=>(e.Verbose="Verbose",e.Information="Information",e.Warning="Warning",e.Error="Error",e.Critical="Critical",e))(p||{}),u=(e=>(e.V2="2.x",e.V3="3.x",e))(u||{}),f={error:"Error",warn:"Warning",info:"Information",verbose:"Verbose"},m=c(e=>null!=e&&"object"==typeof e&&void 0===e.constructor?{...e}:e,"convertNullPrototypeToRegularObject"),v=c((e,...t)=>{const r=["message","name","stack",...t],n={};for(const t of Object.keys(e))if(!r.includes(t)){const r=e[t];n[t]=m(r)}return n},"extractErrorProperties"),y=c((e,r)=>{const n=[];r(e)&&n.push({exception:e,properties:v(e,"level")});const o=e[t.SPLAT];if(null!=o)for(const e of o)r(e)&&n.push({exception:e,properties:v(e)});return n},"extractErrorsStep"),g=c(e=>{const r=String(e.message),n=e[t.SPLAT],o=n?.[0];if(void 0!==o?.message){const e=` ${o.message}`;if(r.endsWith(e))return r.slice(0,-e.length)}return r},"extractMessageStep"),h=c(e=>{if(null==e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t},"isPlainObject"),d=c(e=>{const t=Object.entries(e);if(0===t.length)return null;const r={};for(const[e,n]of t)r[e]=m(n);return r},"extractNonSymbolProps"),x=c((e,t)=>{if(t(e)){const{level:t,message:r,...n}=e;return d(n)}const{level:r,name:n,message:o,stack:i,cause:s,...l}=e;return d(l)},"extractDefaultMeta"),b=c((e,r=e=>e instanceof Error)=>{const n=x(e,r),o=e[t.SPLAT];if(null==o)return n??{};const i=o.filter(e=>!r(e))[0];return null!=i&&h(i)?{...n,...i}:n??{}},"extractPropertiesStep"),E=c((e,t,r)=>{const n=t[e.level];if(null!=n)return n;if(null!=r){const n=r[e.level];if(null!=n){const e=Object.entries(r).map(e=>({levelName:e[0],priority:e[1]})).filter(e=>n<e.priority).sort((e,t)=>e.priority-t.priority);for(const{levelName:r}of e){const e=t[r];if(e)return e}}}return"Verbose"},"extractSeverityStep"),w=c(e=>e instanceof Error,"isError"),S=class extends s.default{static{c(this,"ApplicationInsightsTransport")}telemetryHandler;options;levels;constructor(e){super({level:e.level}),this.options={telemetryHandler:e.telemetryHandler,severityMapping:e.severityMapping??f,isError:e.isError??w,traceFilter:e.traceFilter??(()=>!0),exceptionFilter:e.exceptionFilter??(()=>!0)},this.telemetryHandler=e.telemetryHandler}log(e,t){const r=this.getExceptions(e),n=this.getTrace(e,r);this.telemetryHandler.handleTelemetry({trace:n,exceptions:r}),t()}getTrace(e,t){const r=this.extractTrace(e,t);return null!=r&&this.options.traceFilter(r)?r:null}getExceptions(e){return y(e,this.options.isError).filter(this.options.exceptionFilter)}extractTrace(e,t){if(t.length>0&&this.options.isError(e))return null;return{message:g(e),properties:b(e,this.options.isError),severity:E(e,this.options.severityMapping,this.levels)}}},T=class{static{c(this,"ApplicationInsightsV2TelemetryHandler")}client;severityMapping={Verbose:0,Information:1,Warning:2,Error:3,Critical:4};constructor(e){this.client=e.client}handleTelemetry(e){if(null!=e.trace){const t={message:e.trace.message,severity:this.mapSeverity(e.trace.severity),properties:e.trace.properties};this.client.trackTrace(t)}for(const t of e.exceptions){const e={exception:t.exception,properties:t.properties};this.client.trackException(e)}}mapSeverity(e){return this.severityMapping[e]}},A=class{static{c(this,"ApplicationInsightsV3TelemetryHandler")}client;severityMapping={Verbose:r.KnownSeverityLevel.Verbose,Information:r.KnownSeverityLevel.Information,Warning:r.KnownSeverityLevel.Warning,Error:r.KnownSeverityLevel.Error,Critical:r.KnownSeverityLevel.Critical};constructor(e){this.client=e.client}handleTelemetry(e){if(null!=e.trace){const t={message:e.trace.message,severity:this.mapSeverity(e.trace.severity),properties:e.trace.properties};this.client.trackTrace(t)}for(const t of e.exceptions){const e={exception:t.exception,properties:t.properties};this.client.trackException(e)}}mapSeverity(e){return this.severityMapping[e]}},j=c(e=>{switch(e.version){case"2.x":return new T({client:e.client});case"3.x":return new A({client:e.client});default:return e.telemetryHandler}},"createTelemetryHandler"),I=c(e=>{const t=j(e);return new S({telemetryHandler:t,severityMapping:e.severityMapping,exceptionFilter:e.exceptionFilter,traceFilter:e.traceFilter,isError:e.isError,level:e.level})},"createApplicationInsightsTransport"),M=c(e=>e[t.MESSAGE].replaceAll(/\\u001b/g,""),"unescapeColorCodes"),F=c(()=>l.default.format.printf(M),"unescapeColorCodesFormat"),L=c(e=>{if(Array.isArray(e))return l.default.format.combine(...e);const t=[];return!0===e.timestamp?t.push(l.default.format.timestamp()):"object"==typeof e.timestamp&&t.push(l.default.format.timestamp(e.timestamp)),!0===e.errors?t.push(l.default.format.errors({stack:!0})):"object"==typeof e.errors&&t.push(l.default.format.errors(e.errors)),!0===e.colorize?t.push(l.default.format.colorize({all:!0})):"object"==typeof e.colorize&&t.push(l.default.format.colorize(e.colorize)),"simple"===e.output&&t.push(l.default.format.simple()),"json"===e.output&&(t.push(l.default.format.json()),!0!==e.colorize&&"object"!=typeof e.colorize||t.push(F())),l.default.format.combine(...t)},"createWinstonFormat"),H=c(()=>void 0!==o.env.WEBSITE_INSTANCE_ID,"isRunningInAzure"),V=c(()=>!H(),"isRunningLocally"),W=c(e=>{const{severityMapping:t,exceptionFilter:r,traceFilter:n,isError:o,...i}=e.insights,s=j(i),a=[];if(e.winston?.console?.enabled??V()){let t;if(Array.isArray(e.winston?.console?.format))t=e.winston.console.format;else{const r=e.winston?.console?.format??{};t={output:r.output??"json",timestamp:r.timestamp??!0,errors:r.errors??{stack:!0},colorize:r.colorize??!0}}const r=L(t);a.push(new l.default.transports.Console({format:r,level:e.winston?.console?.level,stderrLevels:["error","crit","alert","emerg"],consoleWarnLevels:["warn","warning"]}))}if(e.winston?.insights?.enabled??!0){const i=I({telemetryHandler:s,severityMapping:t,exceptionFilter:r,traceFilter:n,isError:o,level:e.winston?.insights?.level});a.push(i)}const c=e.winston?.defaults?.level??"info",p=e.winston?.levels??l.default.config.npm.levels,u=e.winston?.defaults?.format??[],f=l.default.format.combine(...u);return l.default.createLogger({...e.winston?.options,level:c,levels:p,format:f,transports:a,defaultMeta:e.winston?.defaults?.defaultMeta})},"createWinstonLogger");exports.ApplicationInsightsVersion=u,exports.TelemetrySeverity=p,exports.createApplicationInsightsTransport=I,exports.createTelemetryHandler=j,exports.createWinstonLogger=W,exports.isRunningInAzure=H,exports.isRunningLocally=V;//# sourceMappingURL=index.cjs.map
1
+ "use strict";var e=require("winston-transport"),t=require("triple-beam"),r=require("applicationinsightsv3"),n=require("winston"),o=require("process");function s(e){return e&&e.__esModule?e:{default:e}}var i=s(e),l=s(n),a=Object.defineProperty,c=(e,t)=>a(e,"name",{value:t,configurable:!0}),p=(e=>(e.Verbose="Verbose",e.Information="Information",e.Warning="Warning",e.Error="Error",e.Critical="Critical",e))(p||{}),u=(e=>(e.V2="2.x",e.V3="3.x",e))(u||{}),f={error:"Error",warn:"Warning",info:"Information",verbose:"Verbose"},m=c(e=>null!=e&&"object"==typeof e&&void 0===e.constructor?{...e}:e,"convertNullPrototypeToRegularObject"),g=c((e,...t)=>{const r=["message","name","stack",...t],n={};for(const t of Object.keys(e))if(!r.includes(t)){const r=e[t];n[t]=m(r)}return n},"extractErrorProperties"),v=c((e,r)=>{const n=[];r(e)&&n.push({exception:e,properties:g(e,"level")});const o=e[t.SPLAT];if(null!=o)for(const e of o)r(e)&&n.push({exception:e,properties:g(e)});return n},"extractErrorsStep"),y=c(e=>{let r=String(e.message);const n=e[t.SPLAT]??[],o=n[0];if(void 0!==o?.message){const e=` ${o.message}`;r.endsWith(e)&&(r=r.slice(0,-e.length))}return{messageAsString:r,splat:n}},"getMessageAsString"),h=c(e=>{const{messageAsString:t,splat:r}=y(e);return[t,...r.filter(e=>"string"==typeof e)].join(" ")},"extractMessageStepInternal"),d=c(e=>h(e),"extractMessageStep"),x=c(e=>{if(null==e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t},"isPlainObject"),b=c(e=>{const t=Object.entries(e);if(0===t.length)return null;const r={};for(const[e,n]of t)r[e]=m(n);return r},"extractNonSymbolProps"),E=c((e,t)=>{if(t(e)){const{level:t,message:r,...n}=e;return b(n)}const{level:r,name:n,message:o,stack:s,cause:i,...l}=e;return b(l)},"extractDefaultMeta"),S=c((e,r=e=>e instanceof Error)=>{const n=E(e,r),o=e[t.SPLAT];if(null==o)return n??{};const s=o.filter(e=>!r(e))[0];return null!=s&&x(s)?{...n,...s}:n??{}},"extractPropertiesStep"),w=c((e,t,r)=>{const n=t[e.level];if(null!=n)return n;if(null!=r){const n=r[e.level];if(null!=n){const e=Object.entries(r).map(e=>({levelName:e[0],priority:e[1]})).filter(e=>n<e.priority).sort((e,t)=>e.priority-t.priority);for(const{levelName:r}of e){const e=t[r];if(e)return e}}}return"Verbose"},"extractSeverityStep"),T=c(e=>e instanceof Error,"isError"),A=class extends i.default{static{c(this,"ApplicationInsightsTransport")}telemetryHandler;options;levels;constructor(e){super({level:e.level}),this.options={telemetryHandler:e.telemetryHandler,severityMapping:e.severityMapping??f,isError:e.isError??T,traceFilter:e.traceFilter??(()=>!0),exceptionFilter:e.exceptionFilter??(()=>!0)},this.telemetryHandler=e.telemetryHandler}log(e,t){const r=this.getExceptions(e),n=this.getTrace(e,r);this.telemetryHandler.handleTelemetry({trace:n,exceptions:r}),t()}getTrace(e,t){const r=this.extractTrace(e,t);return null!=r&&this.options.traceFilter(r)?r:null}getExceptions(e){return v(e,this.options.isError).filter(this.options.exceptionFilter)}extractTrace(e,t){if(t.length>0&&this.options.isError(e))return null;return{message:d(e),properties:S(e,this.options.isError),severity:w(e,this.options.severityMapping,this.levels)}}},M=class{static{c(this,"ApplicationInsightsV2TelemetryHandler")}client;severityMapping={Verbose:0,Information:1,Warning:2,Error:3,Critical:4};constructor(e){this.client=e.client}handleTelemetry(e){if(null!=e.trace){const t={message:e.trace.message,severity:this.mapSeverity(e.trace.severity),properties:e.trace.properties};this.client.trackTrace(t)}for(const t of e.exceptions){const e={exception:t.exception,properties:t.properties};this.client.trackException(e)}}mapSeverity(e){return this.severityMapping[e]}},j=class{static{c(this,"ApplicationInsightsV3TelemetryHandler")}client;severityMapping={Verbose:r.KnownSeverityLevel.Verbose,Information:r.KnownSeverityLevel.Information,Warning:r.KnownSeverityLevel.Warning,Error:r.KnownSeverityLevel.Error,Critical:r.KnownSeverityLevel.Critical};constructor(e){this.client=e.client}handleTelemetry(e){if(null!=e.trace){const t={message:e.trace.message,severity:this.mapSeverity(e.trace.severity),properties:e.trace.properties};this.client.trackTrace(t)}for(const t of e.exceptions){const e={exception:t.exception,properties:t.properties};this.client.trackException(e)}}mapSeverity(e){return this.severityMapping[e]}},I=c(e=>{switch(e.version){case"2.x":return new M({client:e.client});case"3.x":return new j({client:e.client});default:return e.telemetryHandler}},"createTelemetryHandler"),F=c(e=>{const t=I(e);return new A({telemetryHandler:t,severityMapping:e.severityMapping,exceptionFilter:e.exceptionFilter,traceFilter:e.traceFilter,isError:e.isError,level:e.level})},"createApplicationInsightsTransport"),L=c(e=>e[t.MESSAGE].replaceAll(/\\u001b/g,""),"unescapeColorCodes"),H=c(()=>l.default.format.printf(L),"unescapeColorCodesFormat"),V=c(e=>{if(Array.isArray(e))return l.default.format.combine(...e);const t=[];return!0===e.timestamp?t.push(l.default.format.timestamp()):"object"==typeof e.timestamp&&t.push(l.default.format.timestamp(e.timestamp)),!0===e.errors?t.push(l.default.format.errors({stack:!0})):"object"==typeof e.errors&&t.push(l.default.format.errors(e.errors)),!0===e.colorize?t.push(l.default.format.colorize({all:!0})):"object"==typeof e.colorize&&t.push(l.default.format.colorize(e.colorize)),"simple"===e.output&&t.push(l.default.format.simple()),"json"===e.output&&(t.push(l.default.format.json()),!0!==e.colorize&&"object"!=typeof e.colorize||t.push(H())),l.default.format.combine(...t)},"createWinstonFormat"),W=c(()=>void 0!==o.env.WEBSITE_INSTANCE_ID,"isRunningInAzure"),z=c(()=>!W(),"isRunningLocally"),C=c(e=>{const{severityMapping:t,exceptionFilter:r,traceFilter:n,isError:o,...s}=e.insights,i=I(s),a=[];if(e.winston?.console?.enabled??z()){let t;if(Array.isArray(e.winston?.console?.format))t=e.winston.console.format;else{const r=e.winston?.console?.format??{};t={output:r.output??"json",timestamp:r.timestamp??!0,errors:r.errors??{stack:!0},colorize:r.colorize??!0}}const r=V(t);a.push(new l.default.transports.Console({format:r,level:e.winston?.console?.level,stderrLevels:["error","crit","alert","emerg"],consoleWarnLevels:["warn","warning"]}))}if(e.winston?.insights?.enabled??!0){const s=F({telemetryHandler:i,severityMapping:t,exceptionFilter:r,traceFilter:n,isError:o,level:e.winston?.insights?.level});a.push(s)}const c=e.winston?.defaults?.level??"info",p=e.winston?.levels??l.default.config.npm.levels,u=e.winston?.defaults?.format??[],f=l.default.format.combine(...u);return l.default.createLogger({...e.winston?.options,level:c,levels:p,format:f,transports:a,defaultMeta:e.winston?.defaults?.defaultMeta})},"createWinstonLogger");exports.ApplicationInsightsVersion=u,exports.TelemetrySeverity=p,exports.createApplicationInsightsTransport=F,exports.createTelemetryHandler=I,exports.createWinstonLogger=C,exports.isRunningInAzure=W,exports.isRunningLocally=z;//# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/public/enums.ts","../src/private/consts.ts","../src/private/convertNullPrototypeToRegularObject.ts","../src/private/extractErrorsStep.ts","../src/private/extractMessageStep.ts","../src/private/isPlainObject.ts","../src/private/extractPropertiesStep.ts","../src/private/extractSeverityStep.ts","../src/private/isError.ts","../src/private/ApplicationInsightsTransport.ts","../src/private/ApplicationInsightsV2TelemetryHandler.ts","../src/private/ApplicationInsightsV3TelemetryHandler.ts","../src/public/createTelemetryHandler.ts","../src/public/createApplicationInsightsTransport.ts","../src/private/createWinstonFormat.ts","../src/public/isRunningInAzure.ts","../src/public/isRunningLocally.ts","../src/public/createWinstonLogger.ts"],"names":["TelemetrySeverity","ApplicationInsightsVersion","isError","SPLAT","level","message","rest","TransportStream","KnownSeverityLevel","MESSAGE","winston","env"],"mappings":";;;;AAAO,IAAK,iBAAA,qBAAAA,kBAAAA,KAAL;AACL,EAAAA,mBAAA,SAAA,CAAA,GAAU,SAAA;AACV,EAAAA,mBAAA,aAAA,CAAA,GAAc,aAAA;AACd,EAAAA,mBAAA,SAAA,CAAA,GAAU,SAAA;AACV,EAAAA,mBAAA,OAAA,CAAA,GAAQ,OAAA;AACR,EAAAA,mBAAA,UAAA,CAAA,GAAW,UAAA;AALD,EAAA,OAAAA,kBAAAA;AAAA,CAAA,EAAA,iBAAA,IAAA,EAAA;AAQL,IAAK,0BAAA,qBAAAC,2BAAAA,KAAL;AACL,EAAAA,4BAAA,IAAA,CAAA,GAAK,KAAA;AACL,EAAAA,4BAAA,IAAA,CAAA,GAAK,KAAA;AAFK,EAAA,OAAAA,2BAAAA;AAAA,CAAA,EAAA,0BAAA,IAAA,EAAA;;;ACLL,IAAM,sBAAA,GAA0C;AAAA,EACrD,KAAA,EAAA,OAAA;AAAA,EACA,IAAA,EAAA,SAAA;AAAA,EACA,IAAA,EAAA,aAAA;AAAA,EACA,OAAA,EAAA,SAAA;AACF,CAAA;;;ACHO,IAAM,mCAAA,2BAAuC,KAAA,KAA4B;AAC9E,EAAA,IAAI,SAAS,IAAA,IAAQ,OAAO,UAAU,QAAA,IAAY,KAAA,CAAM,gBAAgB,MAAA,EAAW;AACjF,IAAA,OAAO,EAAE,GAAG,KAAA,EAAM;AAAA,EACpB;AACA,EAAA,OAAO,KAAA;AACT,CAAA,EALmD,qCAAA,CAAA;;;ACAnD,IAAM,sBAAA,mBAAyB,MAAA,CAAA,CAAC,KAAA,EAAA,GAAiB,gBAAA,KAAwD;AACvG,EAAA,M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,SAAS;AAAA,OACtC;AAAA,KACH;AAAA,EACF;AAGA,EAAA,MAAM,eAAA,GAAkB,OAAA,CAAQ,OAAA,EAAS,QAAA,EAAU,OAAA,IAAW,IAAA;AAC9D,EAAA,IAAI,eAAA,EAAiB;AACnB,IAAA,MAAM,YAAY,kCAAA,CAAmC;AAAA,MACnD,gBAAA;AAAA,MACA,eAAA;AAAA,MACA,eAAA;AAAA,MACA,WAAA;AAAA,MACA,OAAA,EAAAR,QAAAA;AAAA,MACA,KAAA,EAAO,OAAA,CAAQ,OAAA,EAAS,QAAA,EAAU;AAAA,KACnC,CAAA;AACD,IAAA,UAAA,CAAW,KAAK,SAAS,CAAA;AAAA,EAC3B;AAGA,EAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,OAAA,EAAS,QAAA,EAAU,KAAA,IAAS,MAAA;AAClD,EAAA,MAAM,SAAS,OAAA,CAAQ,OAAA,EAAS,MAAA,IAAUQ,wBAAAA,CAAQ,OAAO,GAAA,CAAI,MAAA;AAC7D,EAAA,MAAM,aAAA,GAAgB,OAAA,CAAQ,OAAA,EAAS,QAAA,EAAU,UAAU,EAAC;AAE5D,EAAA,MAAM,MAAA,GAASA,wBAAAA,CAAQ,MAAA,CAAO,OAAA,CAAQ,GAAG,aAAa,CAAA;AAEtD,EAAA,OAAOA,yBAAQ,YAAA,CAAa;AAAA,IAC1B,GAAG,QAAQ,OAAA,EAAS,OAAA;AAAA,IACpB,KAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,UAAA;AAAA,IACA,WAAA,EAAa,OAAA,CAAQ,OAAA,EAAS,QAAA,EAAU;AAAA,GACzC,CAAA;AACH,CAAA,EAhEmC,qBAAA","file":"index.cjs","sourcesContent":["export enum TelemetrySeverity {\n Verbose = 'Verbose',\n Information = 'Information',\n Warning = 'Warning',\n Error = 'Error',\n Critical = 'Critical',\n}\n\nexport enum ApplicationInsightsVersion {\n V2 = '2.x',\n V3 = '3.x',\n}\n","import { TelemetrySeverity } from '../public/enums';\nimport type { SeverityMapping } from '../public/types';\n\nexport const defaultSeverityMapping: SeverityMapping = {\n error: TelemetrySeverity.Error,\n warn: TelemetrySeverity.Warning,\n info: TelemetrySeverity.Information,\n verbose: TelemetrySeverity.Verbose,\n};\n","/**\n * Ensures that the object returned has a constructor to avoid a {@link TypeError} from the `applicationinsights` library.\n * @param value\n * @returns\n */\nexport const convertNullPrototypeToRegularObject = (value: unknown): unknown => {\n if (value != null && typeof value === 'object' && value.constructor === undefined) {\n return { ...value };\n }\n return value;\n};\n","import { SPLAT } from 'triple-beam';\nimport type { IsError, TelemetryDataException } from '../public/types';\nimport { convertNullPrototypeToRegularObject } from './convertNullPrototypeToRegularObject';\nimport type { WinstonInfo } from './types';\n\nconst extractErrorProperties = (error: Error, ...additionalIgnore: string[]): Record<string, unknown> => {\n const ignore = ['message', 'name', 'stack', ...additionalIgnore];\n const properties: Record<string, unknown> = {};\n for (const key of Object.keys(error) as (keyof Error)[]) {\n if (!ignore.includes(key)) {\n const value = error[key];\n properties[key] = convertNullPrototypeToRegularObject(value);\n }\n }\n return properties;\n};\n\nexport const extractErrorsStep = (info: WinstonInfo, isError: IsError): TelemetryDataException[] => {\n const exceptions: TelemetryDataException[] = [];\n\n if (isError(info)) {\n exceptions.push({\n exception: info,\n properties: extractErrorProperties(info, 'level'),\n });\n }\n\n const splat = info[SPLAT];\n if (splat != null) {\n for (const item of splat) {\n if (isError(item)) {\n exceptions.push({\n exception: item,\n properties: extractErrorProperties(item),\n });\n }\n }\n }\n\n return exceptions;\n};\n","import { SPLAT } from 'triple-beam';\nimport type { WinstonInfo } from './types';\n\nexport const extractMessageStep = (info: WinstonInfo): string => {\n const messageAsString = String(info.message);\n\n const splat = info[SPLAT];\n const meta = splat?.[0] as { message?: unknown };\n\n if (meta?.message !== undefined) {\n const expectedSuffix = ` ${meta.message}`;\n\n if (messageAsString.endsWith(expectedSuffix)) {\n return messageAsString.slice(0, -expectedSuffix.length);\n }\n }\n\n return messageAsString;\n};\n","export const isPlainObject = (obj: unknown): obj is Record<string, unknown> => {\n if (obj == null || typeof obj !== 'object') {\n return false;\n }\n const proto = Object.getPrototypeOf(obj);\n return proto === Object.prototype || proto === null;\n};\n","import { SPLAT } from 'triple-beam';\nimport type { IsError, TelemetryDataProperties } from '../public/types';\nimport { convertNullPrototypeToRegularObject } from './convertNullPrototypeToRegularObject';\nimport { isPlainObject } from './isPlainObject';\nimport type { WinstonInfo } from './types';\n\nconst extractNonSymbolProps = (obj: Record<string | symbol, unknown>): Record<string, unknown> | null => {\n const entries = Object.entries(obj);\n if (entries.length === 0) {\n return null;\n }\n\n const result: Record<string, unknown> = {};\n for (const [key, value] of entries) {\n result[key] = convertNullPrototypeToRegularObject(value);\n }\n return result;\n};\n\nconst extractDefaultMeta = (info: WinstonInfo, isError: IsError): Record<string, unknown> | null => {\n if (isError(info)) {\n const { level, message, ...rest } = info;\n return extractNonSymbolProps(rest);\n }\n const { level, name, message, stack, cause, ...rest } = info;\n return extractNonSymbolProps(rest);\n};\n\nexport const extractPropertiesStep = (info: WinstonInfo, isError: IsError = (x) => x instanceof Error): TelemetryDataProperties => {\n const defaultMeta = extractDefaultMeta(info, isError);\n\n const splat = info[SPLAT];\n if (splat == null) {\n return defaultMeta ?? {};\n }\n\n const nonErrorItems = splat.filter((item) => !isError(item));\n const firstObject = nonErrorItems[0];\n if (firstObject != null && isPlainObject(firstObject)) {\n return { ...defaultMeta, ...firstObject };\n }\n return defaultMeta ?? {};\n};\n","import { TelemetrySeverity } from '../public/enums';\nimport type { SeverityMapping, WinstonLevels } from '../public/types';\nimport type { WinstonInfo } from './types';\n\nexport const extractSeverityStep = (info: WinstonInfo, severityMapping: SeverityMapping, levels?: WinstonLevels): TelemetrySeverity => {\n const directMapping = severityMapping[info.level];\n if (directMapping != null) {\n return directMapping;\n }\n\n if (levels != null) {\n const currentPriority = levels[info.level];\n\n if (currentPriority != null) {\n const sortedLevels = Object.entries(levels)\n .map((x) => ({ levelName: x[0], priority: x[1] }))\n .filter((x) => currentPriority < x.priority)\n .sort((a, b) => a.priority - b.priority);\n\n for (const { levelName } of sortedLevels) {\n const severity = severityMapping[levelName];\n if (severity) {\n return severity;\n }\n }\n }\n }\n\n return TelemetrySeverity.Verbose;\n};\n","export const isError = (item: unknown): item is Error => item instanceof Error;\n","import TransportStream from 'winston-transport';\nimport type { TelemetryDataException, TelemetryHandler, WinstonLevels } from '../public/types';\nimport { defaultSeverityMapping } from './consts';\nimport { extractErrorsStep } from './extractErrorsStep';\nimport { extractMessageStep } from './extractMessageStep';\nimport { extractPropertiesStep } from './extractPropertiesStep';\nimport { extractSeverityStep } from './extractSeverityStep';\nimport { isError } from './isError';\nimport type { ApplicationInsightsTransportOptions, RequiredOptions, WinstonInfo } from './types';\n\nexport class ApplicationInsightsTransport extends TransportStream {\n private readonly telemetryHandler: TelemetryHandler;\n private readonly options: RequiredOptions;\n\n public levels?: WinstonLevels;\n\n constructor(options: ApplicationInsightsTransportOptions) {\n super({\n level: options.level,\n });\n this.options = {\n telemetryHandler: options.telemetryHandler,\n severityMapping: options.severityMapping ?? defaultSeverityMapping,\n isError: options.isError ?? isError,\n traceFilter: options.traceFilter ?? (() => true),\n exceptionFilter: options.exceptionFilter ?? (() => true),\n };\n this.telemetryHandler = options.telemetryHandler;\n }\n\n public override log(info: WinstonInfo, next: () => void) {\n const exceptions = this.getExceptions(info);\n const trace = this.getTrace(info, exceptions);\n\n this.telemetryHandler.handleTelemetry({\n trace,\n exceptions,\n });\n\n next();\n }\n\n private getTrace(info: WinstonInfo, filteredExceptions: TelemetryDataException[]) {\n const trace = this.extractTrace(info, filteredExceptions);\n if (trace != null && this.options.traceFilter(trace)) {\n return trace;\n }\n return null;\n }\n\n private getExceptions(info: WinstonInfo) {\n const exceptions = extractErrorsStep(info, this.options.isError);\n const filtered = exceptions.filter(this.options.exceptionFilter);\n return filtered;\n }\n\n private extractTrace(info: WinstonInfo, errors: TelemetryDataException[]) {\n const shouldSendOnlyException = errors.length > 0 && this.options.isError(info);\n\n if (shouldSendOnlyException) {\n return null;\n }\n\n const message = extractMessageStep(info);\n const properties = extractPropertiesStep(info, this.options.isError);\n const severity = extractSeverityStep(info, this.options.severityMapping, this.levels);\n\n return {\n message: message,\n properties,\n severity,\n };\n }\n}\n","import type { ExceptionTelemetry, TraceTelemetry } from 'applicationinsightsv2/out/Declarations/Contracts';\nimport { TelemetrySeverity } from '../public/enums';\nimport type { ITelemetryClientV2 } from '../public/ITelemetryClientV2';\nimport type { TelemetryData, TelemetryHandler } from '../public/types';\n\n// From application insights\n// Declare locally to avoid importing the library\nenum SeverityLevel {\n Verbose = 0,\n Information = 1,\n Warning = 2,\n Error = 3,\n Critical = 4,\n}\n\nexport interface ApplicationInsightsV2TelemetryHandlerOptions {\n client: ITelemetryClientV2;\n}\n\nexport class ApplicationInsightsV2TelemetryHandler implements TelemetryHandler {\n private readonly client: ITelemetryClientV2;\n private readonly severityMapping: Record<TelemetrySeverity, SeverityLevel> = {\n [TelemetrySeverity.Verbose]: SeverityLevel.Verbose,\n [TelemetrySeverity.Information]: SeverityLevel.Information,\n [TelemetrySeverity.Warning]: SeverityLevel.Warning,\n [TelemetrySeverity.Error]: SeverityLevel.Error,\n [TelemetrySeverity.Critical]: SeverityLevel.Critical,\n };\n\n constructor(options: ApplicationInsightsV2TelemetryHandlerOptions) {\n this.client = options.client;\n }\n\n public handleTelemetry(telemetry: TelemetryData): void {\n if (telemetry.trace != null) {\n const trace: TraceTelemetry = {\n message: telemetry.trace.message,\n severity: this.mapSeverity(telemetry.trace.severity),\n properties: telemetry.trace.properties,\n };\n this.client.trackTrace(trace);\n }\n\n for (const error of telemetry.exceptions) {\n const exceptionTelemetry = {\n exception: error.exception,\n properties: error.properties,\n } satisfies ExceptionTelemetry;\n\n this.client.trackException(exceptionTelemetry);\n }\n }\n\n private mapSeverity(severity: TelemetrySeverity): SeverityLevel {\n return this.severityMapping[severity];\n }\n}\n","import type { ExceptionTelemetry, TraceTelemetry } from 'applicationinsightsv3';\nimport { KnownSeverityLevel } from 'applicationinsightsv3';\nimport { TelemetrySeverity } from '../public/enums';\nimport type { ITelemetryClientV3 } from '../public/ITelemetryClientV3';\nimport type { TelemetryData, TelemetryHandler } from '../public/types';\n\nexport interface ApplicationInsightsV3TelemetryHandlerOptions {\n client: ITelemetryClientV3;\n}\n\nexport class ApplicationInsightsV3TelemetryHandler implements TelemetryHandler {\n private readonly client: ITelemetryClientV3;\n private readonly severityMapping: Record<TelemetrySeverity, KnownSeverityLevel> = {\n [TelemetrySeverity.Verbose]: KnownSeverityLevel.Verbose,\n [TelemetrySeverity.Information]: KnownSeverityLevel.Information,\n [TelemetrySeverity.Warning]: KnownSeverityLevel.Warning,\n [TelemetrySeverity.Error]: KnownSeverityLevel.Error,\n [TelemetrySeverity.Critical]: KnownSeverityLevel.Critical,\n };\n\n constructor(options: ApplicationInsightsV3TelemetryHandlerOptions) {\n this.client = options.client;\n }\n\n public handleTelemetry(telemetry: TelemetryData): void {\n if (telemetry.trace != null) {\n const trace: TraceTelemetry = {\n message: telemetry.trace.message,\n severity: this.mapSeverity(telemetry.trace.severity),\n properties: telemetry.trace.properties,\n };\n this.client.trackTrace(trace);\n }\n\n for (const error of telemetry.exceptions) {\n const exceptionTelemetry = {\n exception: error.exception,\n properties: error.properties,\n } satisfies ExceptionTelemetry;\n\n this.client.trackException(exceptionTelemetry);\n }\n }\n\n private mapSeverity(severity: TelemetrySeverity): KnownSeverityLevel {\n return this.severityMapping[severity];\n }\n}\n","import { ApplicationInsightsV2TelemetryHandler } from '../private/ApplicationInsightsV2TelemetryHandler';\nimport { ApplicationInsightsV3TelemetryHandler } from '../private/ApplicationInsightsV3TelemetryHandler';\nimport { ApplicationInsightsVersion } from './enums';\nimport type { CreateTelemetryHandlerOptions, TelemetryHandler } from './types';\n\nexport const createTelemetryHandler = (options: CreateTelemetryHandlerOptions): TelemetryHandler => {\n switch (options.version) {\n case ApplicationInsightsVersion.V2: {\n return new ApplicationInsightsV2TelemetryHandler({\n client: options.client,\n });\n }\n case ApplicationInsightsVersion.V3: {\n return new ApplicationInsightsV3TelemetryHandler({\n client: options.client,\n });\n }\n default: {\n return options.telemetryHandler;\n }\n }\n};\n","import type TransportStream from 'winston-transport';\nimport { ApplicationInsightsTransport } from '../private/ApplicationInsightsTransport';\nimport { createTelemetryHandler } from './createTelemetryHandler';\nimport type { CreateApplicationInsightsTransportOptions } from './types';\n\nexport const createApplicationInsightsTransport = (options: CreateApplicationInsightsTransportOptions): TransportStream => {\n const telemetryHandler = createTelemetryHandler(options);\n\n const transport = new ApplicationInsightsTransport({\n telemetryHandler,\n severityMapping: options.severityMapping,\n exceptionFilter: options.exceptionFilter,\n traceFilter: options.traceFilter,\n isError: options.isError,\n level: options.level,\n });\n\n return transport;\n};\n","import type { ColorizeOptions, Format, TimestampOptions, TransformableInfo } from 'logform';\nimport { MESSAGE } from 'triple-beam';\nimport winston from 'winston';\n\n/**\n * Converts escaped ANSI color codes back to actual ANSI escape sequences.\n * Specifically converts `\\\\u001b` (escaped) to `\\u001b` (ESC character, ^[ or 0x1B).\n * @see https://github.com/winstonjs/logform#colorize\n */\nconst unescapeColorCodes = (info: TransformableInfo) => {\n const message = info[MESSAGE] as string;\n return message.replaceAll(/\\\\u001b/g, '\\u001b');\n};\n\nconst unescapeColorCodesFormat = () => winston.format.printf(unescapeColorCodes);\n\nexport type CreateWinstonFormatOptions =\n | Format[]\n | {\n output: 'json' | 'simple';\n errors: boolean | { stack?: boolean };\n timestamp: boolean | TimestampOptions;\n colorize: boolean | ColorizeOptions;\n };\n\nexport const createWinstonFormat = (config: CreateWinstonFormatOptions): Format => {\n if (Array.isArray(config)) {\n return winston.format.combine(...config);\n }\n\n const formats: Format[] = [];\n\n if (config.timestamp === true) {\n formats.push(winston.format.timestamp());\n } else if (typeof config.timestamp === 'object') {\n formats.push(winston.format.timestamp(config.timestamp));\n }\n\n if (config.errors === true) {\n formats.push(winston.format.errors({ stack: true }));\n } else if (typeof config.errors === 'object') {\n formats.push(winston.format.errors(config.errors));\n }\n\n if (config.colorize === true) {\n formats.push(winston.format.colorize({ all: true }));\n } else if (typeof config.colorize === 'object') {\n formats.push(winston.format.colorize(config.colorize));\n }\n\n if (config.output === 'simple') {\n formats.push(winston.format.simple());\n }\n if (config.output === 'json') {\n formats.push(winston.format.json());\n\n if (config.colorize === true || typeof config.colorize === 'object') {\n formats.push(unescapeColorCodesFormat());\n }\n }\n\n return winston.format.combine(...formats);\n};\n","import { env } from 'node:process';\n\nexport const isRunningInAzure = () => {\n return env.WEBSITE_INSTANCE_ID !== undefined;\n};\n","import { isRunningInAzure } from './isRunningInAzure';\n\nexport const isRunningLocally = () => {\n return !isRunningInAzure();\n};\n","import winston from 'winston';\nimport type TransportStream from 'winston-transport';\nimport { type CreateWinstonFormatOptions, createWinstonFormat } from '../private/createWinstonFormat';\nimport { createApplicationInsightsTransport } from './createApplicationInsightsTransport';\nimport { createTelemetryHandler } from './createTelemetryHandler';\nimport { isRunningLocally } from './isRunningLocally';\nimport type { CreateWinstonLoggerOptions } from './types';\n\nexport const createWinstonLogger = (options: CreateWinstonLoggerOptions): winston.Logger => {\n const { severityMapping, exceptionFilter, traceFilter, isError, ...rest } = options.insights;\n\n const telemetryHandler = createTelemetryHandler(rest);\n\n const transports: TransportStream[] = [];\n\n const consoleEnabled = options.winston?.console?.enabled ?? isRunningLocally();\n if (consoleEnabled) {\n let consoleFormatConfig: CreateWinstonFormatOptions | undefined;\n\n if (Array.isArray(options.winston?.console?.format)) {\n consoleFormatConfig = options.winston.console.format;\n } else {\n const userFormat = options.winston?.console?.format ?? {};\n consoleFormatConfig = {\n output: userFormat.output ?? 'json',\n timestamp: userFormat.timestamp ?? true,\n errors: userFormat.errors ?? { stack: true },\n colorize: userFormat.colorize ?? true,\n };\n }\n\n const consoleFormat = createWinstonFormat(consoleFormatConfig);\n\n transports.push(\n new winston.transports.Console({\n format: consoleFormat,\n level: options.winston?.console?.level,\n stderrLevels: ['error', 'crit', 'alert', 'emerg'],\n consoleWarnLevels: ['warn', 'warning'],\n }),\n );\n }\n\n // Insights transport\n const insightsEnabled = options.winston?.insights?.enabled ?? true;\n if (insightsEnabled) {\n const transport = createApplicationInsightsTransport({\n telemetryHandler,\n severityMapping,\n exceptionFilter,\n traceFilter,\n isError,\n level: options.winston?.insights?.level,\n });\n transports.push(transport);\n }\n\n // Merge defaults with logger-level options\n const level = options.winston?.defaults?.level ?? 'info';\n const levels = options.winston?.levels ?? winston.config.npm.levels;\n const globalFormats = options.winston?.defaults?.format ?? [];\n\n const format = winston.format.combine(...globalFormats);\n\n return winston.createLogger({\n ...options.winston?.options,\n level,\n levels,\n format,\n transports,\n defaultMeta: options.winston?.defaults?.defaultMeta,\n });\n};\n"]}
1
+ {"version":3,"sources":["../src/public/enums.ts","../src/private/consts.ts","../src/private/convertNullPrototypeToRegularObject.ts","../src/private/extractErrorsStep.ts","../src/private/extractMessageStep.ts","../src/private/isPlainObject.ts","../src/private/extractPropertiesStep.ts","../src/private/extractSeverityStep.ts","../src/private/isError.ts","../src/private/ApplicationInsightsTransport.ts","../src/private/ApplicationInsightsV2TelemetryHandler.ts","../src/private/ApplicationInsightsV3TelemetryHandler.ts","../src/public/createTelemetryHandler.ts","../src/public/createApplicationInsightsTransport.ts","../src/private/createWinstonFormat.ts","../src/public/isRunningInAzure.ts","../src/public/isRunningLocally.ts","../src/public/createWinstonLogger.ts"],"names":["TelemetrySeverity","ApplicationInsightsVersion","isError","SPLAT","level","message","rest","TransportStream","KnownSeverityLevel","MESSAGE","winston","env"],"mappings":";;;;AAAO,IAAK,iBAAA,qBAAAA,kBAAAA,KAAL;AACL,EAAAA,mBAAA,SAAA,CAAA,GAAU,SAAA;AACV,EAAAA,mBAAA,aAAA,CAAA,GAAc,aAAA;AACd,EAAAA,mBAAA,SAAA,CAAA,GAAU,SAAA;AACV,EAAAA,mBAAA,OAAA,CAAA,GAAQ,OAAA;AACR,EAAAA,mBAAA,UAAA,CAAA,GAAW,UAAA;AALD,EAAA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,iBAAA,EAAmB,CAAC,MAAA,EAAQ,SAAS;AAAA,OACtC;AAAA,KACH;AAAA,EACF;AAGA,EAAA,MAAM,eAAA,GAAkB,OAAA,CAAQ,OAAA,EAAS,QAAA,EAAU,OAAA,IAAW,IAAA;AAC9D,EAAA,IAAI,eAAA,EAAiB;AACnB,IAAA,MAAM,YAAY,kCAAA,CAAmC;AAAA,MACnD,gBAAA;AAAA,MACA,eAAA;AAAA,MACA,eAAA;AAAA,MACA,WAAA;AAAA,MACA,OAAA,EAAAR,QAAAA;AAAA,MACA,KAAA,EAAO,OAAA,CAAQ,OAAA,EAAS,QAAA,EAAU;AAAA,KACnC,CAAA;AACD,IAAA,UAAA,CAAW,KAAK,SAAS,CAAA;AAAA,EAC3B;AAGA,EAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,OAAA,EAAS,QAAA,EAAU,KAAA,IAAS,MAAA;AAClD,EAAA,MAAM,SAAS,OAAA,CAAQ,OAAA,EAAS,MAAA,IAAUQ,wBAAAA,CAAQ,OAAO,GAAA,CAAI,MAAA;AAC7D,EAAA,MAAM,aAAA,GAAgB,OAAA,CAAQ,OAAA,EAAS,QAAA,EAAU,UAAU,EAAC;AAE5D,EAAA,MAAM,MAAA,GAASA,wBAAAA,CAAQ,MAAA,CAAO,OAAA,CAAQ,GAAG,aAAa,CAAA;AAEtD,EAAA,OAAOA,yBAAQ,YAAA,CAAa;AAAA,IAC1B,GAAG,QAAQ,OAAA,EAAS,OAAA;AAAA,IACpB,KAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,UAAA;AAAA,IACA,WAAA,EAAa,OAAA,CAAQ,OAAA,EAAS,QAAA,EAAU;AAAA,GACzC,CAAA;AACH,CAAA,EAhEmC,qBAAA","file":"index.cjs","sourcesContent":["export enum TelemetrySeverity {\n Verbose = 'Verbose',\n Information = 'Information',\n Warning = 'Warning',\n Error = 'Error',\n Critical = 'Critical',\n}\n\nexport enum ApplicationInsightsVersion {\n V2 = '2.x',\n V3 = '3.x',\n}\n","import { TelemetrySeverity } from '../public/enums';\nimport type { SeverityMapping } from '../public/types';\n\nexport const defaultSeverityMapping: SeverityMapping = {\n error: TelemetrySeverity.Error,\n warn: TelemetrySeverity.Warning,\n info: TelemetrySeverity.Information,\n verbose: TelemetrySeverity.Verbose,\n};\n","/**\n * Ensures that the object returned has a constructor to avoid a {@link TypeError} from the `applicationinsights` library.\n * @param value\n * @returns\n */\nexport const convertNullPrototypeToRegularObject = (value: unknown): unknown => {\n if (value != null && typeof value === 'object' && value.constructor === undefined) {\n return { ...value };\n }\n return value;\n};\n","import { SPLAT } from 'triple-beam';\nimport type { IsError, TelemetryDataException } from '../public/types';\nimport { convertNullPrototypeToRegularObject } from './convertNullPrototypeToRegularObject';\nimport type { WinstonInfo } from './types';\n\nconst extractErrorProperties = (error: Error, ...additionalIgnore: string[]): Record<string, unknown> => {\n const ignore = ['message', 'name', 'stack', ...additionalIgnore];\n const properties: Record<string, unknown> = {};\n for (const key of Object.keys(error) as (keyof Error)[]) {\n if (!ignore.includes(key)) {\n const value = error[key];\n properties[key] = convertNullPrototypeToRegularObject(value);\n }\n }\n return properties;\n};\n\nexport const extractErrorsStep = (info: WinstonInfo, isError: IsError): TelemetryDataException[] => {\n const exceptions: TelemetryDataException[] = [];\n\n if (isError(info)) {\n exceptions.push({\n exception: info,\n properties: extractErrorProperties(info, 'level'),\n });\n }\n\n const splat = info[SPLAT];\n if (splat != null) {\n for (const item of splat) {\n if (isError(item)) {\n exceptions.push({\n exception: item,\n properties: extractErrorProperties(item),\n });\n }\n }\n }\n\n return exceptions;\n};\n","import { SPLAT } from 'triple-beam';\nimport type { WinstonInfo } from './types';\n\nconst getMessageAsString = (info: WinstonInfo) => {\n let messageAsString = String(info.message);\n const splat = info[SPLAT] ?? [];\n const meta = splat[0] as { message?: unknown };\n\n if (meta?.message !== undefined) {\n const expectedSuffix = ` ${meta.message}`;\n if (messageAsString.endsWith(expectedSuffix)) {\n messageAsString = messageAsString.slice(0, -expectedSuffix.length);\n }\n }\n\n return { messageAsString, splat };\n};\n\nconst extractMessageStepInternal = (info: WinstonInfo): string => {\n const { messageAsString, splat } = getMessageAsString(info);\n const strings = splat.filter((x) => typeof x === 'string');\n return [messageAsString, ...strings].join(' ');\n};\n\nexport const extractMessageStep = (info: WinstonInfo): string => {\n const result = extractMessageStepInternal(info);\n return result;\n};\n","export const isPlainObject = (obj: unknown): obj is Record<string, unknown> => {\n if (obj == null || typeof obj !== 'object') {\n return false;\n }\n const proto = Object.getPrototypeOf(obj);\n return proto === Object.prototype || proto === null;\n};\n","import { SPLAT } from 'triple-beam';\nimport type { IsError, TelemetryDataProperties } from '../public/types';\nimport { convertNullPrototypeToRegularObject } from './convertNullPrototypeToRegularObject';\nimport { isPlainObject } from './isPlainObject';\nimport type { WinstonInfo } from './types';\n\nconst extractNonSymbolProps = (obj: Record<string | symbol, unknown>): Record<string, unknown> | null => {\n const entries = Object.entries(obj);\n if (entries.length === 0) {\n return null;\n }\n\n const result: Record<string, unknown> = {};\n for (const [key, value] of entries) {\n result[key] = convertNullPrototypeToRegularObject(value);\n }\n return result;\n};\n\nconst extractDefaultMeta = (info: WinstonInfo, isError: IsError): Record<string, unknown> | null => {\n if (isError(info)) {\n const { level, message, ...rest } = info;\n return extractNonSymbolProps(rest);\n }\n const { level, name, message, stack, cause, ...rest } = info;\n return extractNonSymbolProps(rest);\n};\n\nexport const extractPropertiesStep = (info: WinstonInfo, isError: IsError = (x) => x instanceof Error): TelemetryDataProperties => {\n const defaultMeta = extractDefaultMeta(info, isError);\n\n const splat = info[SPLAT];\n if (splat == null) {\n return defaultMeta ?? {};\n }\n\n const nonErrorItems = splat.filter((item) => !isError(item));\n const firstObject = nonErrorItems[0];\n if (firstObject != null && isPlainObject(firstObject)) {\n return { ...defaultMeta, ...firstObject };\n }\n return defaultMeta ?? {};\n};\n","import { TelemetrySeverity } from '../public/enums';\nimport type { SeverityMapping, WinstonLevels } from '../public/types';\nimport type { WinstonInfo } from './types';\n\nexport const extractSeverityStep = (info: WinstonInfo, severityMapping: SeverityMapping, levels?: WinstonLevels): TelemetrySeverity => {\n const directMapping = severityMapping[info.level];\n if (directMapping != null) {\n return directMapping;\n }\n\n if (levels != null) {\n const currentPriority = levels[info.level];\n\n if (currentPriority != null) {\n const sortedLevels = Object.entries(levels)\n .map((x) => ({ levelName: x[0], priority: x[1] }))\n .filter((x) => currentPriority < x.priority)\n .sort((a, b) => a.priority - b.priority);\n\n for (const { levelName } of sortedLevels) {\n const severity = severityMapping[levelName];\n if (severity) {\n return severity;\n }\n }\n }\n }\n\n return TelemetrySeverity.Verbose;\n};\n","export const isError = (item: unknown): item is Error => item instanceof Error;\n","import TransportStream from 'winston-transport';\nimport type { TelemetryDataException, TelemetryHandler, WinstonLevels } from '../public/types';\nimport { defaultSeverityMapping } from './consts';\nimport { extractErrorsStep } from './extractErrorsStep';\nimport { extractMessageStep } from './extractMessageStep';\nimport { extractPropertiesStep } from './extractPropertiesStep';\nimport { extractSeverityStep } from './extractSeverityStep';\nimport { isError } from './isError';\nimport type { ApplicationInsightsTransportOptions, RequiredOptions, WinstonInfo } from './types';\n\nexport class ApplicationInsightsTransport extends TransportStream {\n private readonly telemetryHandler: TelemetryHandler;\n private readonly options: RequiredOptions;\n\n public levels?: WinstonLevels;\n\n constructor(options: ApplicationInsightsTransportOptions) {\n super({\n level: options.level,\n });\n this.options = {\n telemetryHandler: options.telemetryHandler,\n severityMapping: options.severityMapping ?? defaultSeverityMapping,\n isError: options.isError ?? isError,\n traceFilter: options.traceFilter ?? (() => true),\n exceptionFilter: options.exceptionFilter ?? (() => true),\n };\n this.telemetryHandler = options.telemetryHandler;\n }\n\n public override log(info: WinstonInfo, next: () => void) {\n const exceptions = this.getExceptions(info);\n const trace = this.getTrace(info, exceptions);\n\n this.telemetryHandler.handleTelemetry({\n trace,\n exceptions,\n });\n\n next();\n }\n\n private getTrace(info: WinstonInfo, filteredExceptions: TelemetryDataException[]) {\n const trace = this.extractTrace(info, filteredExceptions);\n if (trace != null && this.options.traceFilter(trace)) {\n return trace;\n }\n return null;\n }\n\n private getExceptions(info: WinstonInfo) {\n const exceptions = extractErrorsStep(info, this.options.isError);\n const filtered = exceptions.filter(this.options.exceptionFilter);\n return filtered;\n }\n\n private extractTrace(info: WinstonInfo, errors: TelemetryDataException[]) {\n const shouldSendOnlyException = errors.length > 0 && this.options.isError(info);\n\n if (shouldSendOnlyException) {\n return null;\n }\n\n const message = extractMessageStep(info);\n const properties = extractPropertiesStep(info, this.options.isError);\n const severity = extractSeverityStep(info, this.options.severityMapping, this.levels);\n\n return {\n message: message,\n properties,\n severity,\n };\n }\n}\n","import type { ExceptionTelemetry, TraceTelemetry } from 'applicationinsightsv2/out/Declarations/Contracts';\nimport { TelemetrySeverity } from '../public/enums';\nimport type { ITelemetryClientV2 } from '../public/ITelemetryClientV2';\nimport type { TelemetryData, TelemetryHandler } from '../public/types';\n\n// From application insights\n// Declare locally to avoid importing the library\nenum SeverityLevel {\n Verbose = 0,\n Information = 1,\n Warning = 2,\n Error = 3,\n Critical = 4,\n}\n\nexport interface ApplicationInsightsV2TelemetryHandlerOptions {\n client: ITelemetryClientV2;\n}\n\nexport class ApplicationInsightsV2TelemetryHandler implements TelemetryHandler {\n private readonly client: ITelemetryClientV2;\n private readonly severityMapping: Record<TelemetrySeverity, SeverityLevel> = {\n [TelemetrySeverity.Verbose]: SeverityLevel.Verbose,\n [TelemetrySeverity.Information]: SeverityLevel.Information,\n [TelemetrySeverity.Warning]: SeverityLevel.Warning,\n [TelemetrySeverity.Error]: SeverityLevel.Error,\n [TelemetrySeverity.Critical]: SeverityLevel.Critical,\n };\n\n constructor(options: ApplicationInsightsV2TelemetryHandlerOptions) {\n this.client = options.client;\n }\n\n public handleTelemetry(telemetry: TelemetryData): void {\n if (telemetry.trace != null) {\n const trace: TraceTelemetry = {\n message: telemetry.trace.message,\n severity: this.mapSeverity(telemetry.trace.severity),\n properties: telemetry.trace.properties,\n };\n this.client.trackTrace(trace);\n }\n\n for (const error of telemetry.exceptions) {\n const exceptionTelemetry = {\n exception: error.exception,\n properties: error.properties,\n } satisfies ExceptionTelemetry;\n\n this.client.trackException(exceptionTelemetry);\n }\n }\n\n private mapSeverity(severity: TelemetrySeverity): SeverityLevel {\n return this.severityMapping[severity];\n }\n}\n","import type { ExceptionTelemetry, TraceTelemetry } from 'applicationinsightsv3';\nimport { KnownSeverityLevel } from 'applicationinsightsv3';\nimport { TelemetrySeverity } from '../public/enums';\nimport type { ITelemetryClientV3 } from '../public/ITelemetryClientV3';\nimport type { TelemetryData, TelemetryHandler } from '../public/types';\n\nexport interface ApplicationInsightsV3TelemetryHandlerOptions {\n client: ITelemetryClientV3;\n}\n\nexport class ApplicationInsightsV3TelemetryHandler implements TelemetryHandler {\n private readonly client: ITelemetryClientV3;\n private readonly severityMapping: Record<TelemetrySeverity, KnownSeverityLevel> = {\n [TelemetrySeverity.Verbose]: KnownSeverityLevel.Verbose,\n [TelemetrySeverity.Information]: KnownSeverityLevel.Information,\n [TelemetrySeverity.Warning]: KnownSeverityLevel.Warning,\n [TelemetrySeverity.Error]: KnownSeverityLevel.Error,\n [TelemetrySeverity.Critical]: KnownSeverityLevel.Critical,\n };\n\n constructor(options: ApplicationInsightsV3TelemetryHandlerOptions) {\n this.client = options.client;\n }\n\n public handleTelemetry(telemetry: TelemetryData): void {\n if (telemetry.trace != null) {\n const trace: TraceTelemetry = {\n message: telemetry.trace.message,\n severity: this.mapSeverity(telemetry.trace.severity),\n properties: telemetry.trace.properties,\n };\n this.client.trackTrace(trace);\n }\n\n for (const error of telemetry.exceptions) {\n const exceptionTelemetry = {\n exception: error.exception,\n properties: error.properties,\n } satisfies ExceptionTelemetry;\n\n this.client.trackException(exceptionTelemetry);\n }\n }\n\n private mapSeverity(severity: TelemetrySeverity): KnownSeverityLevel {\n return this.severityMapping[severity];\n }\n}\n","import { ApplicationInsightsV2TelemetryHandler } from '../private/ApplicationInsightsV2TelemetryHandler';\nimport { ApplicationInsightsV3TelemetryHandler } from '../private/ApplicationInsightsV3TelemetryHandler';\nimport { ApplicationInsightsVersion } from './enums';\nimport type { CreateTelemetryHandlerOptions, TelemetryHandler } from './types';\n\nexport const createTelemetryHandler = (options: CreateTelemetryHandlerOptions): TelemetryHandler => {\n switch (options.version) {\n case ApplicationInsightsVersion.V2: {\n return new ApplicationInsightsV2TelemetryHandler({\n client: options.client,\n });\n }\n case ApplicationInsightsVersion.V3: {\n return new ApplicationInsightsV3TelemetryHandler({\n client: options.client,\n });\n }\n default: {\n return options.telemetryHandler;\n }\n }\n};\n","import type TransportStream from 'winston-transport';\nimport { ApplicationInsightsTransport } from '../private/ApplicationInsightsTransport';\nimport { createTelemetryHandler } from './createTelemetryHandler';\nimport type { CreateApplicationInsightsTransportOptions } from './types';\n\nexport const createApplicationInsightsTransport = (options: CreateApplicationInsightsTransportOptions): TransportStream => {\n const telemetryHandler = createTelemetryHandler(options);\n\n const transport = new ApplicationInsightsTransport({\n telemetryHandler,\n severityMapping: options.severityMapping,\n exceptionFilter: options.exceptionFilter,\n traceFilter: options.traceFilter,\n isError: options.isError,\n level: options.level,\n });\n\n return transport;\n};\n","import type { ColorizeOptions, Format, TimestampOptions, TransformableInfo } from 'logform';\nimport { MESSAGE } from 'triple-beam';\nimport winston from 'winston';\n\n/**\n * Converts escaped ANSI color codes back to actual ANSI escape sequences.\n * Specifically converts `\\\\u001b` (escaped) to `\\u001b` (ESC character, ^[ or 0x1B).\n * @see https://github.com/winstonjs/logform#colorize\n */\nconst unescapeColorCodes = (info: TransformableInfo) => {\n const message = info[MESSAGE] as string;\n return message.replaceAll(/\\\\u001b/g, '\\u001b');\n};\n\nconst unescapeColorCodesFormat = () => winston.format.printf(unescapeColorCodes);\n\nexport type CreateWinstonFormatOptions =\n | Format[]\n | {\n output: 'json' | 'simple';\n errors: boolean | { stack?: boolean };\n timestamp: boolean | TimestampOptions;\n colorize: boolean | ColorizeOptions;\n };\n\nexport const createWinstonFormat = (config: CreateWinstonFormatOptions): Format => {\n if (Array.isArray(config)) {\n return winston.format.combine(...config);\n }\n\n const formats: Format[] = [];\n\n if (config.timestamp === true) {\n formats.push(winston.format.timestamp());\n } else if (typeof config.timestamp === 'object') {\n formats.push(winston.format.timestamp(config.timestamp));\n }\n\n if (config.errors === true) {\n formats.push(winston.format.errors({ stack: true }));\n } else if (typeof config.errors === 'object') {\n formats.push(winston.format.errors(config.errors));\n }\n\n if (config.colorize === true) {\n formats.push(winston.format.colorize({ all: true }));\n } else if (typeof config.colorize === 'object') {\n formats.push(winston.format.colorize(config.colorize));\n }\n\n if (config.output === 'simple') {\n formats.push(winston.format.simple());\n }\n if (config.output === 'json') {\n formats.push(winston.format.json());\n\n if (config.colorize === true || typeof config.colorize === 'object') {\n formats.push(unescapeColorCodesFormat());\n }\n }\n\n return winston.format.combine(...formats);\n};\n","import { env } from 'node:process';\n\nexport const isRunningInAzure = () => {\n return env.WEBSITE_INSTANCE_ID !== undefined;\n};\n","import { isRunningInAzure } from './isRunningInAzure';\n\nexport const isRunningLocally = () => {\n return !isRunningInAzure();\n};\n","import winston from 'winston';\nimport type TransportStream from 'winston-transport';\nimport { type CreateWinstonFormatOptions, createWinstonFormat } from '../private/createWinstonFormat';\nimport { createApplicationInsightsTransport } from './createApplicationInsightsTransport';\nimport { createTelemetryHandler } from './createTelemetryHandler';\nimport { isRunningLocally } from './isRunningLocally';\nimport type { CreateWinstonLoggerOptions } from './types';\n\nexport const createWinstonLogger = (options: CreateWinstonLoggerOptions): winston.Logger => {\n const { severityMapping, exceptionFilter, traceFilter, isError, ...rest } = options.insights;\n\n const telemetryHandler = createTelemetryHandler(rest);\n\n const transports: TransportStream[] = [];\n\n const consoleEnabled = options.winston?.console?.enabled ?? isRunningLocally();\n if (consoleEnabled) {\n let consoleFormatConfig: CreateWinstonFormatOptions | undefined;\n\n if (Array.isArray(options.winston?.console?.format)) {\n consoleFormatConfig = options.winston.console.format;\n } else {\n const userFormat = options.winston?.console?.format ?? {};\n consoleFormatConfig = {\n output: userFormat.output ?? 'json',\n timestamp: userFormat.timestamp ?? true,\n errors: userFormat.errors ?? { stack: true },\n colorize: userFormat.colorize ?? true,\n };\n }\n\n const consoleFormat = createWinstonFormat(consoleFormatConfig);\n\n transports.push(\n new winston.transports.Console({\n format: consoleFormat,\n level: options.winston?.console?.level,\n stderrLevels: ['error', 'crit', 'alert', 'emerg'],\n consoleWarnLevels: ['warn', 'warning'],\n }),\n );\n }\n\n // Insights transport\n const insightsEnabled = options.winston?.insights?.enabled ?? true;\n if (insightsEnabled) {\n const transport = createApplicationInsightsTransport({\n telemetryHandler,\n severityMapping,\n exceptionFilter,\n traceFilter,\n isError,\n level: options.winston?.insights?.level,\n });\n transports.push(transport);\n }\n\n // Merge defaults with logger-level options\n const level = options.winston?.defaults?.level ?? 'info';\n const levels = options.winston?.levels ?? winston.config.npm.levels;\n const globalFormats = options.winston?.defaults?.format ?? [];\n\n const format = winston.format.combine(...globalFormats);\n\n return winston.createLogger({\n ...options.winston?.options,\n level,\n levels,\n format,\n transports,\n defaultMeta: options.winston?.defaults?.defaultMeta,\n });\n};\n"]}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import e from"winston-transport";import{SPLAT as t,MESSAGE as r}from"triple-beam";import{KnownSeverityLevel as o}from"applicationinsightsv3";import i from"winston";import{env as n}from"process";var s=Object.defineProperty,l=(e,t)=>s(e,"name",{value:t,configurable:!0}),a=(e=>(e.Verbose="Verbose",e.Information="Information",e.Warning="Warning",e.Error="Error",e.Critical="Critical",e))(a||{}),c=(e=>(e.V2="2.x",e.V3="3.x",e))(c||{}),p={error:"Error",warn:"Warning",info:"Information",verbose:"Verbose"},m=l(e=>null!=e&&"object"==typeof e&&void 0===e.constructor?{...e}:e,"convertNullPrototypeToRegularObject"),u=l((e,...t)=>{const r=["message","name","stack",...t],o={};for(const t of Object.keys(e))if(!r.includes(t)){const r=e[t];o[t]=m(r)}return o},"extractErrorProperties"),f=l((e,r)=>{const o=[];r(e)&&o.push({exception:e,properties:u(e,"level")});const i=e[t];if(null!=i)for(const e of i)r(e)&&o.push({exception:e,properties:u(e)});return o},"extractErrorsStep"),g=l(e=>{const r=String(e.message),o=e[t],i=o?.[0];if(void 0!==i?.message){const e=` ${i.message}`;if(r.endsWith(e))return r.slice(0,-e.length)}return r},"extractMessageStep"),y=l(e=>{if(null==e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t},"isPlainObject"),h=l(e=>{const t=Object.entries(e);if(0===t.length)return null;const r={};for(const[e,o]of t)r[e]=m(o);return r},"extractNonSymbolProps"),v=l((e,t)=>{if(t(e)){const{level:t,message:r,...o}=e;return h(o)}const{level:r,name:o,message:i,stack:n,cause:s,...l}=e;return h(l)},"extractDefaultMeta"),x=l((e,r=e=>e instanceof Error)=>{const o=v(e,r),i=e[t];if(null==i)return o??{};const n=i.filter(e=>!r(e))[0];return null!=n&&y(n)?{...o,...n}:o??{}},"extractPropertiesStep"),d=l((e,t,r)=>{const o=t[e.level];if(null!=o)return o;if(null!=r){const o=r[e.level];if(null!=o){const e=Object.entries(r).map(e=>({levelName:e[0],priority:e[1]})).filter(e=>o<e.priority).sort((e,t)=>e.priority-t.priority);for(const{levelName:r}of e){const e=t[r];if(e)return e}}}return"Verbose"},"extractSeverityStep"),b=l(e=>e instanceof Error,"isError"),E=class extends e{static{l(this,"ApplicationInsightsTransport")}telemetryHandler;options;levels;constructor(e){super({level:e.level}),this.options={telemetryHandler:e.telemetryHandler,severityMapping:e.severityMapping??p,isError:e.isError??b,traceFilter:e.traceFilter??(()=>!0),exceptionFilter:e.exceptionFilter??(()=>!0)},this.telemetryHandler=e.telemetryHandler}log(e,t){const r=this.getExceptions(e),o=this.getTrace(e,r);this.telemetryHandler.handleTelemetry({trace:o,exceptions:r}),t()}getTrace(e,t){const r=this.extractTrace(e,t);return null!=r&&this.options.traceFilter(r)?r:null}getExceptions(e){return f(e,this.options.isError).filter(this.options.exceptionFilter)}extractTrace(e,t){if(t.length>0&&this.options.isError(e))return null;return{message:g(e),properties:x(e,this.options.isError),severity:d(e,this.options.severityMapping,this.levels)}}},w=class{static{l(this,"ApplicationInsightsV2TelemetryHandler")}client;severityMapping={Verbose:0,Information:1,Warning:2,Error:3,Critical:4};constructor(e){this.client=e.client}handleTelemetry(e){if(null!=e.trace){const t={message:e.trace.message,severity:this.mapSeverity(e.trace.severity),properties:e.trace.properties};this.client.trackTrace(t)}for(const t of e.exceptions){const e={exception:t.exception,properties:t.properties};this.client.trackException(e)}}mapSeverity(e){return this.severityMapping[e]}},j=class{static{l(this,"ApplicationInsightsV3TelemetryHandler")}client;severityMapping={Verbose:o.Verbose,Information:o.Information,Warning:o.Warning,Error:o.Error,Critical:o.Critical};constructor(e){this.client=e.client}handleTelemetry(e){if(null!=e.trace){const t={message:e.trace.message,severity:this.mapSeverity(e.trace.severity),properties:e.trace.properties};this.client.trackTrace(t)}for(const t of e.exceptions){const e={exception:t.exception,properties:t.properties};this.client.trackException(e)}}mapSeverity(e){return this.severityMapping[e]}},T=l(e=>{switch(e.version){case"2.x":return new w({client:e.client});case"3.x":return new j({client:e.client});default:return e.telemetryHandler}},"createTelemetryHandler"),F=l(e=>{const t=T(e);return new E({telemetryHandler:t,severityMapping:e.severityMapping,exceptionFilter:e.exceptionFilter,traceFilter:e.traceFilter,isError:e.isError,level:e.level})},"createApplicationInsightsTransport"),M=l(e=>e[r].replaceAll(/\\u001b/g,""),"unescapeColorCodes"),I=l(()=>i.format.printf(M),"unescapeColorCodesFormat"),S=l(e=>{if(Array.isArray(e))return i.format.combine(...e);const t=[];return!0===e.timestamp?t.push(i.format.timestamp()):"object"==typeof e.timestamp&&t.push(i.format.timestamp(e.timestamp)),!0===e.errors?t.push(i.format.errors({stack:!0})):"object"==typeof e.errors&&t.push(i.format.errors(e.errors)),!0===e.colorize?t.push(i.format.colorize({all:!0})):"object"==typeof e.colorize&&t.push(i.format.colorize(e.colorize)),"simple"===e.output&&t.push(i.format.simple()),"json"===e.output&&(t.push(i.format.json()),!0!==e.colorize&&"object"!=typeof e.colorize||t.push(I())),i.format.combine(...t)},"createWinstonFormat"),H=l(()=>void 0!==n.WEBSITE_INSTANCE_ID,"isRunningInAzure"),A=l(()=>!H(),"isRunningLocally"),C=l(e=>{const{severityMapping:t,exceptionFilter:r,traceFilter:o,isError:n,...s}=e.insights,l=T(s),a=[];if(e.winston?.console?.enabled??A()){let t;if(Array.isArray(e.winston?.console?.format))t=e.winston.console.format;else{const r=e.winston?.console?.format??{};t={output:r.output??"json",timestamp:r.timestamp??!0,errors:r.errors??{stack:!0},colorize:r.colorize??!0}}const r=S(t);a.push(new i.transports.Console({format:r,level:e.winston?.console?.level,stderrLevels:["error","crit","alert","emerg"],consoleWarnLevels:["warn","warning"]}))}if(e.winston?.insights?.enabled??!0){const i=F({telemetryHandler:l,severityMapping:t,exceptionFilter:r,traceFilter:o,isError:n,level:e.winston?.insights?.level});a.push(i)}const c=e.winston?.defaults?.level??"info",p=e.winston?.levels??i.config.npm.levels,m=e.winston?.defaults?.format??[],u=i.format.combine(...m);return i.createLogger({...e.winston?.options,level:c,levels:p,format:u,transports:a,defaultMeta:e.winston?.defaults?.defaultMeta})},"createWinstonLogger");export{c as ApplicationInsightsVersion,a as TelemetrySeverity,F as createApplicationInsightsTransport,T as createTelemetryHandler,C as createWinstonLogger,H as isRunningInAzure,A as isRunningLocally};//# sourceMappingURL=index.js.map
1
+ import e from"winston-transport";import{SPLAT as t,MESSAGE as r}from"triple-beam";import{KnownSeverityLevel as o}from"applicationinsightsv3";import s from"winston";import{env as n}from"process";var i=Object.defineProperty,l=(e,t)=>i(e,"name",{value:t,configurable:!0}),a=(e=>(e.Verbose="Verbose",e.Information="Information",e.Warning="Warning",e.Error="Error",e.Critical="Critical",e))(a||{}),c=(e=>(e.V2="2.x",e.V3="3.x",e))(c||{}),p={error:"Error",warn:"Warning",info:"Information",verbose:"Verbose"},m=l(e=>null!=e&&"object"==typeof e&&void 0===e.constructor?{...e}:e,"convertNullPrototypeToRegularObject"),u=l((e,...t)=>{const r=["message","name","stack",...t],o={};for(const t of Object.keys(e))if(!r.includes(t)){const r=e[t];o[t]=m(r)}return o},"extractErrorProperties"),f=l((e,r)=>{const o=[];r(e)&&o.push({exception:e,properties:u(e,"level")});const s=e[t];if(null!=s)for(const e of s)r(e)&&o.push({exception:e,properties:u(e)});return o},"extractErrorsStep"),g=l(e=>{let r=String(e.message);const o=e[t]??[],s=o[0];if(void 0!==s?.message){const e=` ${s.message}`;r.endsWith(e)&&(r=r.slice(0,-e.length))}return{messageAsString:r,splat:o}},"getMessageAsString"),y=l(e=>{const{messageAsString:t,splat:r}=g(e);return[t,...r.filter(e=>"string"==typeof e)].join(" ")},"extractMessageStepInternal"),h=l(e=>y(e),"extractMessageStep"),v=l(e=>{if(null==e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t},"isPlainObject"),x=l(e=>{const t=Object.entries(e);if(0===t.length)return null;const r={};for(const[e,o]of t)r[e]=m(o);return r},"extractNonSymbolProps"),d=l((e,t)=>{if(t(e)){const{level:t,message:r,...o}=e;return x(o)}const{level:r,name:o,message:s,stack:n,cause:i,...l}=e;return x(l)},"extractDefaultMeta"),b=l((e,r=e=>e instanceof Error)=>{const o=d(e,r),s=e[t];if(null==s)return o??{};const n=s.filter(e=>!r(e))[0];return null!=n&&v(n)?{...o,...n}:o??{}},"extractPropertiesStep"),E=l((e,t,r)=>{const o=t[e.level];if(null!=o)return o;if(null!=r){const o=r[e.level];if(null!=o){const e=Object.entries(r).map(e=>({levelName:e[0],priority:e[1]})).filter(e=>o<e.priority).sort((e,t)=>e.priority-t.priority);for(const{levelName:r}of e){const e=t[r];if(e)return e}}}return"Verbose"},"extractSeverityStep"),w=l(e=>e instanceof Error,"isError"),j=class extends e{static{l(this,"ApplicationInsightsTransport")}telemetryHandler;options;levels;constructor(e){super({level:e.level}),this.options={telemetryHandler:e.telemetryHandler,severityMapping:e.severityMapping??p,isError:e.isError??w,traceFilter:e.traceFilter??(()=>!0),exceptionFilter:e.exceptionFilter??(()=>!0)},this.telemetryHandler=e.telemetryHandler}log(e,t){const r=this.getExceptions(e),o=this.getTrace(e,r);this.telemetryHandler.handleTelemetry({trace:o,exceptions:r}),t()}getTrace(e,t){const r=this.extractTrace(e,t);return null!=r&&this.options.traceFilter(r)?r:null}getExceptions(e){return f(e,this.options.isError).filter(this.options.exceptionFilter)}extractTrace(e,t){if(t.length>0&&this.options.isError(e))return null;return{message:h(e),properties:b(e,this.options.isError),severity:E(e,this.options.severityMapping,this.levels)}}},M=class{static{l(this,"ApplicationInsightsV2TelemetryHandler")}client;severityMapping={Verbose:0,Information:1,Warning:2,Error:3,Critical:4};constructor(e){this.client=e.client}handleTelemetry(e){if(null!=e.trace){const t={message:e.trace.message,severity:this.mapSeverity(e.trace.severity),properties:e.trace.properties};this.client.trackTrace(t)}for(const t of e.exceptions){const e={exception:t.exception,properties:t.properties};this.client.trackException(e)}}mapSeverity(e){return this.severityMapping[e]}},S=class{static{l(this,"ApplicationInsightsV3TelemetryHandler")}client;severityMapping={Verbose:o.Verbose,Information:o.Information,Warning:o.Warning,Error:o.Error,Critical:o.Critical};constructor(e){this.client=e.client}handleTelemetry(e){if(null!=e.trace){const t={message:e.trace.message,severity:this.mapSeverity(e.trace.severity),properties:e.trace.properties};this.client.trackTrace(t)}for(const t of e.exceptions){const e={exception:t.exception,properties:t.properties};this.client.trackException(e)}}mapSeverity(e){return this.severityMapping[e]}},T=l(e=>{switch(e.version){case"2.x":return new M({client:e.client});case"3.x":return new S({client:e.client});default:return e.telemetryHandler}},"createTelemetryHandler"),F=l(e=>{const t=T(e);return new j({telemetryHandler:t,severityMapping:e.severityMapping,exceptionFilter:e.exceptionFilter,traceFilter:e.traceFilter,isError:e.isError,level:e.level})},"createApplicationInsightsTransport"),I=l(e=>e[r].replaceAll(/\\u001b/g,""),"unescapeColorCodes"),A=l(()=>s.format.printf(I),"unescapeColorCodesFormat"),H=l(e=>{if(Array.isArray(e))return s.format.combine(...e);const t=[];return!0===e.timestamp?t.push(s.format.timestamp()):"object"==typeof e.timestamp&&t.push(s.format.timestamp(e.timestamp)),!0===e.errors?t.push(s.format.errors({stack:!0})):"object"==typeof e.errors&&t.push(s.format.errors(e.errors)),!0===e.colorize?t.push(s.format.colorize({all:!0})):"object"==typeof e.colorize&&t.push(s.format.colorize(e.colorize)),"simple"===e.output&&t.push(s.format.simple()),"json"===e.output&&(t.push(s.format.json()),!0!==e.colorize&&"object"!=typeof e.colorize||t.push(A())),s.format.combine(...t)},"createWinstonFormat"),C=l(()=>void 0!==n.WEBSITE_INSTANCE_ID,"isRunningInAzure"),V=l(()=>!C(),"isRunningLocally"),W=l(e=>{const{severityMapping:t,exceptionFilter:r,traceFilter:o,isError:n,...i}=e.insights,l=T(i),a=[];if(e.winston?.console?.enabled??V()){let t;if(Array.isArray(e.winston?.console?.format))t=e.winston.console.format;else{const r=e.winston?.console?.format??{};t={output:r.output??"json",timestamp:r.timestamp??!0,errors:r.errors??{stack:!0},colorize:r.colorize??!0}}const r=H(t);a.push(new s.transports.Console({format:r,level:e.winston?.console?.level,stderrLevels:["error","crit","alert","emerg"],consoleWarnLevels:["warn","warning"]}))}if(e.winston?.insights?.enabled??!0){const s=F({telemetryHandler:l,severityMapping:t,exceptionFilter:r,traceFilter:o,isError:n,level:e.winston?.insights?.level});a.push(s)}const c=e.winston?.defaults?.level??"info",p=e.winston?.levels??s.config.npm.levels,m=e.winston?.defaults?.format??[],u=s.format.combine(...m);return s.createLogger({...e.winston?.options,level:c,levels:p,format:u,transports:a,defaultMeta:e.winston?.defaults?.defaultMeta})},"createWinstonLogger");export{c as ApplicationInsightsVersion,a as TelemetrySeverity,F as createApplicationInsightsTransport,T as createTelemetryHandler,W as createWinstonLogger,C as isRunningInAzure,V as isRunningLocally};//# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/public/enums.ts","../src/private/consts.ts","../src/private/convertNullPrototypeToRegularObject.ts","../src/private/extractErrorsStep.ts","../src/private/extractMessageStep.ts","../src/private/isPlainObject.ts","../src/private/extractPropertiesStep.ts","../src/private/extractSeverityStep.ts","../src/private/isError.ts","../src/private/ApplicationInsightsTransport.ts","../src/private/ApplicationInsightsV2TelemetryHandler.ts","../src/private/ApplicationInsightsV3TelemetryHandler.ts","../src/public/createTelemetryHandler.ts","../src/public/createApplicationInsightsTransport.ts","../src/private/createWinstonFormat.ts","../src/public/isRunningInAzure.ts","../src/public/isRunningLocally.ts","../src/public/createWinstonLogger.ts"],"names":["TelemetrySeverity","ApplicationInsightsVersion","isError","SPLAT","level","message","rest","winston"],"mappings":";;;;AAAO,IAAK,iBAAA,qBAAAA,kBAAAA,KAAL;AACL,EAAAA,mBAAA,SAAA,CAAA,GAAU,SAAA;AACV,EAAAA,mBAAA,aAAA,CAAA,GAAc,aAAA;AACd,EAAAA,mBAAA,SAAA,CAAA,GAAU,SAAA;AACV,EAAAA,mBAAA,OAAA,CAAA,GAAQ,OAAA;AACR,EAAAA,mBAAA,UAAA,CAAA,GAAW,UAAA;AALD,EAAA,OAAAA,kBAAAA;AAAA,CAAA,EAAA,iBAAA,IAAA,EAAA;AAQL,IAAK,0BAAA,qBAAAC,2BAAAA,KAAL;AACL,EAAAA,4BAAA,IAAA,CAAA,GAAK,KAAA;AACL,EAAAA,4BAAA,IAAA,CAAA,GAAK,KAAA;AAFK,EAAA,OAAAA,2BAAAA;AAAA,CAAA,EAAA,0BAAA,IAAA,EAAA;;;ACLL,IAAM,sBAAA,GAA0C;AAAA,EACrD,KAAA,EAAA,OAAA;AAAA,EACA,IAAA,EAAA,SAAA;AAAA,EACA,IAAA,EAAA,aAAA;AAAA,EACA,OAAA,EAAA,SAAA;AACF,CAAA;;;ACHO,IAAM,mCAAA,2BAAuC,KAAA,KAA4B;AAC9E,EAAA,IAAI,SAAS,IAAA,IAAQ,OAAO,UAAU,QAAA,IAAY,KAAA,CAAM,gBAAgB,MAAA,EAAW;AACjF,IAAA,O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verbose = 'Verbose',\n Information = 'Information',\n Warning = 'Warning',\n Error = 'Error',\n Critical = 'Critical',\n}\n\nexport enum ApplicationInsightsVersion {\n V2 = '2.x',\n V3 = '3.x',\n}\n","import { TelemetrySeverity } from '../public/enums';\nimport type { SeverityMapping } from '../public/types';\n\nexport const defaultSeverityMapping: SeverityMapping = {\n error: TelemetrySeverity.Error,\n warn: TelemetrySeverity.Warning,\n info: TelemetrySeverity.Information,\n verbose: TelemetrySeverity.Verbose,\n};\n","/**\n * Ensures that the object returned has a constructor to avoid a {@link TypeError} from the `applicationinsights` library.\n * @param value\n * @returns\n */\nexport const convertNullPrototypeToRegularObject = (value: unknown): unknown => {\n if (value != null && typeof value === 'object' && value.constructor === undefined) {\n return { ...value };\n }\n return value;\n};\n","import { SPLAT } from 'triple-beam';\nimport type { IsError, TelemetryDataException } from '../public/types';\nimport { convertNullPrototypeToRegularObject } from './convertNullPrototypeToRegularObject';\nimport type { WinstonInfo } from './types';\n\nconst extractErrorProperties = (error: Error, ...additionalIgnore: string[]): Record<string, unknown> => {\n const ignore = ['message', 'name', 'stack', ...additionalIgnore];\n const properties: Record<string, unknown> = {};\n for (const key of Object.keys(error) as (keyof Error)[]) {\n if (!ignore.includes(key)) {\n const value = error[key];\n properties[key] = convertNullPrototypeToRegularObject(value);\n }\n }\n return properties;\n};\n\nexport const extractErrorsStep = (info: WinstonInfo, isError: IsError): TelemetryDataException[] => {\n const exceptions: TelemetryDataException[] = [];\n\n if (isError(info)) {\n exceptions.push({\n exception: info,\n properties: extractErrorProperties(info, 'level'),\n });\n }\n\n const splat = info[SPLAT];\n if (splat != null) {\n for (const item of splat) {\n if (isError(item)) {\n exceptions.push({\n exception: item,\n properties: extractErrorProperties(item),\n });\n }\n }\n }\n\n return exceptions;\n};\n","import { SPLAT } from 'triple-beam';\nimport type { WinstonInfo } from './types';\n\nexport const extractMessageStep = (info: WinstonInfo): string => {\n const messageAsString = String(info.message);\n\n const splat = info[SPLAT];\n const meta = splat?.[0] as { message?: unknown };\n\n if (meta?.message !== undefined) {\n const expectedSuffix = ` ${meta.message}`;\n\n if (messageAsString.endsWith(expectedSuffix)) {\n return messageAsString.slice(0, -expectedSuffix.length);\n }\n }\n\n return messageAsString;\n};\n","export const isPlainObject = (obj: unknown): obj is Record<string, unknown> => {\n if (obj == null || typeof obj !== 'object') {\n return false;\n }\n const proto = Object.getPrototypeOf(obj);\n return proto === Object.prototype || proto === null;\n};\n","import { SPLAT } from 'triple-beam';\nimport type { IsError, TelemetryDataProperties } from '../public/types';\nimport { convertNullPrototypeToRegularObject } from './convertNullPrototypeToRegularObject';\nimport { isPlainObject } from './isPlainObject';\nimport type { WinstonInfo } from './types';\n\nconst extractNonSymbolProps = (obj: Record<string | symbol, unknown>): Record<string, unknown> | null => {\n const entries = Object.entries(obj);\n if (entries.length === 0) {\n return null;\n }\n\n const result: Record<string, unknown> = {};\n for (const [key, value] of entries) {\n result[key] = convertNullPrototypeToRegularObject(value);\n }\n return result;\n};\n\nconst extractDefaultMeta = (info: WinstonInfo, isError: IsError): Record<string, unknown> | null => {\n if (isError(info)) {\n const { level, message, ...rest } = info;\n return extractNonSymbolProps(rest);\n }\n const { level, name, message, stack, cause, ...rest } = info;\n return extractNonSymbolProps(rest);\n};\n\nexport const extractPropertiesStep = (info: WinstonInfo, isError: IsError = (x) => x instanceof Error): TelemetryDataProperties => {\n const defaultMeta = extractDefaultMeta(info, isError);\n\n const splat = info[SPLAT];\n if (splat == null) {\n return defaultMeta ?? {};\n }\n\n const nonErrorItems = splat.filter((item) => !isError(item));\n const firstObject = nonErrorItems[0];\n if (firstObject != null && isPlainObject(firstObject)) {\n return { ...defaultMeta, ...firstObject };\n }\n return defaultMeta ?? {};\n};\n","import { TelemetrySeverity } from '../public/enums';\nimport type { SeverityMapping, WinstonLevels } from '../public/types';\nimport type { WinstonInfo } from './types';\n\nexport const extractSeverityStep = (info: WinstonInfo, severityMapping: SeverityMapping, levels?: WinstonLevels): TelemetrySeverity => {\n const directMapping = severityMapping[info.level];\n if (directMapping != null) {\n return directMapping;\n }\n\n if (levels != null) {\n const currentPriority = levels[info.level];\n\n if (currentPriority != null) {\n const sortedLevels = Object.entries(levels)\n .map((x) => ({ levelName: x[0], priority: x[1] }))\n .filter((x) => currentPriority < x.priority)\n .sort((a, b) => a.priority - b.priority);\n\n for (const { levelName } of sortedLevels) {\n const severity = severityMapping[levelName];\n if (severity) {\n return severity;\n }\n }\n }\n }\n\n return TelemetrySeverity.Verbose;\n};\n","export const isError = (item: unknown): item is Error => item instanceof Error;\n","import TransportStream from 'winston-transport';\nimport type { TelemetryDataException, TelemetryHandler, WinstonLevels } from '../public/types';\nimport { defaultSeverityMapping } from './consts';\nimport { extractErrorsStep } from './extractErrorsStep';\nimport { extractMessageStep } from './extractMessageStep';\nimport { extractPropertiesStep } from './extractPropertiesStep';\nimport { extractSeverityStep } from './extractSeverityStep';\nimport { isError } from './isError';\nimport type { ApplicationInsightsTransportOptions, RequiredOptions, WinstonInfo } from './types';\n\nexport class ApplicationInsightsTransport extends TransportStream {\n private readonly telemetryHandler: TelemetryHandler;\n private readonly options: RequiredOptions;\n\n public levels?: WinstonLevels;\n\n constructor(options: ApplicationInsightsTransportOptions) {\n super({\n level: options.level,\n });\n this.options = {\n telemetryHandler: options.telemetryHandler,\n severityMapping: options.severityMapping ?? defaultSeverityMapping,\n isError: options.isError ?? isError,\n traceFilter: options.traceFilter ?? (() => true),\n exceptionFilter: options.exceptionFilter ?? (() => true),\n };\n this.telemetryHandler = options.telemetryHandler;\n }\n\n public override log(info: WinstonInfo, next: () => void) {\n const exceptions = this.getExceptions(info);\n const trace = this.getTrace(info, exceptions);\n\n this.telemetryHandler.handleTelemetry({\n trace,\n exceptions,\n });\n\n next();\n }\n\n private getTrace(info: WinstonInfo, filteredExceptions: TelemetryDataException[]) {\n const trace = this.extractTrace(info, filteredExceptions);\n if (trace != null && this.options.traceFilter(trace)) {\n return trace;\n }\n return null;\n }\n\n private getExceptions(info: WinstonInfo) {\n const exceptions = extractErrorsStep(info, this.options.isError);\n const filtered = exceptions.filter(this.options.exceptionFilter);\n return filtered;\n }\n\n private extractTrace(info: WinstonInfo, errors: TelemetryDataException[]) {\n const shouldSendOnlyException = errors.length > 0 && this.options.isError(info);\n\n if (shouldSendOnlyException) {\n return null;\n }\n\n const message = extractMessageStep(info);\n const properties = extractPropertiesStep(info, this.options.isError);\n const severity = extractSeverityStep(info, this.options.severityMapping, this.levels);\n\n return {\n message: message,\n properties,\n severity,\n };\n }\n}\n","import type { ExceptionTelemetry, TraceTelemetry } from 'applicationinsightsv2/out/Declarations/Contracts';\nimport { TelemetrySeverity } from '../public/enums';\nimport type { ITelemetryClientV2 } from '../public/ITelemetryClientV2';\nimport type { TelemetryData, TelemetryHandler } from '../public/types';\n\n// From application insights\n// Declare locally to avoid importing the library\nenum SeverityLevel {\n Verbose = 0,\n Information = 1,\n Warning = 2,\n Error = 3,\n Critical = 4,\n}\n\nexport interface ApplicationInsightsV2TelemetryHandlerOptions {\n client: ITelemetryClientV2;\n}\n\nexport class ApplicationInsightsV2TelemetryHandler implements TelemetryHandler {\n private readonly client: ITelemetryClientV2;\n private readonly severityMapping: Record<TelemetrySeverity, SeverityLevel> = {\n [TelemetrySeverity.Verbose]: SeverityLevel.Verbose,\n [TelemetrySeverity.Information]: SeverityLevel.Information,\n [TelemetrySeverity.Warning]: SeverityLevel.Warning,\n [TelemetrySeverity.Error]: SeverityLevel.Error,\n [TelemetrySeverity.Critical]: SeverityLevel.Critical,\n };\n\n constructor(options: ApplicationInsightsV2TelemetryHandlerOptions) {\n this.client = options.client;\n }\n\n public handleTelemetry(telemetry: TelemetryData): void {\n if (telemetry.trace != null) {\n const trace: TraceTelemetry = {\n message: telemetry.trace.message,\n severity: this.mapSeverity(telemetry.trace.severity),\n properties: telemetry.trace.properties,\n };\n this.client.trackTrace(trace);\n }\n\n for (const error of telemetry.exceptions) {\n const exceptionTelemetry = {\n exception: error.exception,\n properties: error.properties,\n } satisfies ExceptionTelemetry;\n\n this.client.trackException(exceptionTelemetry);\n }\n }\n\n private mapSeverity(severity: TelemetrySeverity): SeverityLevel {\n return this.severityMapping[severity];\n }\n}\n","import type { ExceptionTelemetry, TraceTelemetry } from 'applicationinsightsv3';\nimport { KnownSeverityLevel } from 'applicationinsightsv3';\nimport { TelemetrySeverity } from '../public/enums';\nimport type { ITelemetryClientV3 } from '../public/ITelemetryClientV3';\nimport type { TelemetryData, TelemetryHandler } from '../public/types';\n\nexport interface ApplicationInsightsV3TelemetryHandlerOptions {\n client: ITelemetryClientV3;\n}\n\nexport class ApplicationInsightsV3TelemetryHandler implements TelemetryHandler {\n private readonly client: ITelemetryClientV3;\n private readonly severityMapping: Record<TelemetrySeverity, KnownSeverityLevel> = {\n [TelemetrySeverity.Verbose]: KnownSeverityLevel.Verbose,\n [TelemetrySeverity.Information]: KnownSeverityLevel.Information,\n [TelemetrySeverity.Warning]: KnownSeverityLevel.Warning,\n [TelemetrySeverity.Error]: KnownSeverityLevel.Error,\n [TelemetrySeverity.Critical]: KnownSeverityLevel.Critical,\n };\n\n constructor(options: ApplicationInsightsV3TelemetryHandlerOptions) {\n this.client = options.client;\n }\n\n public handleTelemetry(telemetry: TelemetryData): void {\n if (telemetry.trace != null) {\n const trace: TraceTelemetry = {\n message: telemetry.trace.message,\n severity: this.mapSeverity(telemetry.trace.severity),\n properties: telemetry.trace.properties,\n };\n this.client.trackTrace(trace);\n }\n\n for (const error of telemetry.exceptions) {\n const exceptionTelemetry = {\n exception: error.exception,\n properties: error.properties,\n } satisfies ExceptionTelemetry;\n\n this.client.trackException(exceptionTelemetry);\n }\n }\n\n private mapSeverity(severity: TelemetrySeverity): KnownSeverityLevel {\n return this.severityMapping[severity];\n }\n}\n","import { ApplicationInsightsV2TelemetryHandler } from '../private/ApplicationInsightsV2TelemetryHandler';\nimport { ApplicationInsightsV3TelemetryHandler } from '../private/ApplicationInsightsV3TelemetryHandler';\nimport { ApplicationInsightsVersion } from './enums';\nimport type { CreateTelemetryHandlerOptions, TelemetryHandler } from './types';\n\nexport const createTelemetryHandler = (options: CreateTelemetryHandlerOptions): TelemetryHandler => {\n switch (options.version) {\n case ApplicationInsightsVersion.V2: {\n return new ApplicationInsightsV2TelemetryHandler({\n client: options.client,\n });\n }\n case ApplicationInsightsVersion.V3: {\n return new ApplicationInsightsV3TelemetryHandler({\n client: options.client,\n });\n }\n default: {\n return options.telemetryHandler;\n }\n }\n};\n","import type TransportStream from 'winston-transport';\nimport { ApplicationInsightsTransport } from '../private/ApplicationInsightsTransport';\nimport { createTelemetryHandler } from './createTelemetryHandler';\nimport type { CreateApplicationInsightsTransportOptions } from './types';\n\nexport const createApplicationInsightsTransport = (options: CreateApplicationInsightsTransportOptions): TransportStream => {\n const telemetryHandler = createTelemetryHandler(options);\n\n const transport = new ApplicationInsightsTransport({\n telemetryHandler,\n severityMapping: options.severityMapping,\n exceptionFilter: options.exceptionFilter,\n traceFilter: options.traceFilter,\n isError: options.isError,\n level: options.level,\n });\n\n return transport;\n};\n","import type { ColorizeOptions, Format, TimestampOptions, TransformableInfo } from 'logform';\nimport { MESSAGE } from 'triple-beam';\nimport winston from 'winston';\n\n/**\n * Converts escaped ANSI color codes back to actual ANSI escape sequences.\n * Specifically converts `\\\\u001b` (escaped) to `\\u001b` (ESC character, ^[ or 0x1B).\n * @see https://github.com/winstonjs/logform#colorize\n */\nconst unescapeColorCodes = (info: TransformableInfo) => {\n const message = info[MESSAGE] as string;\n return message.replaceAll(/\\\\u001b/g, '\\u001b');\n};\n\nconst unescapeColorCodesFormat = () => winston.format.printf(unescapeColorCodes);\n\nexport type CreateWinstonFormatOptions =\n | Format[]\n | {\n output: 'json' | 'simple';\n errors: boolean | { stack?: boolean };\n timestamp: boolean | TimestampOptions;\n colorize: boolean | ColorizeOptions;\n };\n\nexport const createWinstonFormat = (config: CreateWinstonFormatOptions): Format => {\n if (Array.isArray(config)) {\n return winston.format.combine(...config);\n }\n\n const formats: Format[] = [];\n\n if (config.timestamp === true) {\n formats.push(winston.format.timestamp());\n } else if (typeof config.timestamp === 'object') {\n formats.push(winston.format.timestamp(config.timestamp));\n }\n\n if (config.errors === true) {\n formats.push(winston.format.errors({ stack: true }));\n } else if (typeof config.errors === 'object') {\n formats.push(winston.format.errors(config.errors));\n }\n\n if (config.colorize === true) {\n formats.push(winston.format.colorize({ all: true }));\n } else if (typeof config.colorize === 'object') {\n formats.push(winston.format.colorize(config.colorize));\n }\n\n if (config.output === 'simple') {\n formats.push(winston.format.simple());\n }\n if (config.output === 'json') {\n formats.push(winston.format.json());\n\n if (config.colorize === true || typeof config.colorize === 'object') {\n formats.push(unescapeColorCodesFormat());\n }\n }\n\n return winston.format.combine(...formats);\n};\n","import { env } from 'node:process';\n\nexport const isRunningInAzure = () => {\n return env.WEBSITE_INSTANCE_ID !== undefined;\n};\n","import { isRunningInAzure } from './isRunningInAzure';\n\nexport const isRunningLocally = () => {\n return !isRunningInAzure();\n};\n","import winston from 'winston';\nimport type TransportStream from 'winston-transport';\nimport { type CreateWinstonFormatOptions, createWinstonFormat } from '../private/createWinstonFormat';\nimport { createApplicationInsightsTransport } from './createApplicationInsightsTransport';\nimport { createTelemetryHandler } from './createTelemetryHandler';\nimport { isRunningLocally } from './isRunningLocally';\nimport type { CreateWinstonLoggerOptions } from './types';\n\nexport const createWinstonLogger = (options: CreateWinstonLoggerOptions): winston.Logger => {\n const { severityMapping, exceptionFilter, traceFilter, isError, ...rest } = options.insights;\n\n const telemetryHandler = createTelemetryHandler(rest);\n\n const transports: TransportStream[] = [];\n\n const consoleEnabled = options.winston?.console?.enabled ?? isRunningLocally();\n if (consoleEnabled) {\n let consoleFormatConfig: CreateWinstonFormatOptions | undefined;\n\n if (Array.isArray(options.winston?.console?.format)) {\n consoleFormatConfig = options.winston.console.format;\n } else {\n const userFormat = options.winston?.console?.format ?? {};\n consoleFormatConfig = {\n output: userFormat.output ?? 'json',\n timestamp: userFormat.timestamp ?? true,\n errors: userFormat.errors ?? { stack: true },\n colorize: userFormat.colorize ?? true,\n };\n }\n\n const consoleFormat = createWinstonFormat(consoleFormatConfig);\n\n transports.push(\n new winston.transports.Console({\n format: consoleFormat,\n level: options.winston?.console?.level,\n stderrLevels: ['error', 'crit', 'alert', 'emerg'],\n consoleWarnLevels: ['warn', 'warning'],\n }),\n );\n }\n\n // Insights transport\n const insightsEnabled = options.winston?.insights?.enabled ?? true;\n if (insightsEnabled) {\n const transport = createApplicationInsightsTransport({\n telemetryHandler,\n severityMapping,\n exceptionFilter,\n traceFilter,\n isError,\n level: options.winston?.insights?.level,\n });\n transports.push(transport);\n }\n\n // Merge defaults with logger-level options\n const level = options.winston?.defaults?.level ?? 'info';\n const levels = options.winston?.levels ?? winston.config.npm.levels;\n const globalFormats = options.winston?.defaults?.format ?? [];\n\n const format = winston.format.combine(...globalFormats);\n\n return winston.createLogger({\n ...options.winston?.options,\n level,\n levels,\n format,\n transports,\n defaultMeta: options.winston?.defaults?.defaultMeta,\n });\n};\n"]}
1
+ {"version":3,"sources":["../src/public/enums.ts","../src/private/consts.ts","../src/private/convertNullPrototypeToRegularObject.ts","../src/private/extractErrorsStep.ts","../src/private/extractMessageStep.ts","../src/private/isPlainObject.ts","../src/private/extractPropertiesStep.ts","../src/private/extractSeverityStep.ts","../src/private/isError.ts","../src/private/ApplicationInsightsTransport.ts","../src/private/ApplicationInsightsV2TelemetryHandler.ts","../src/private/ApplicationInsightsV3TelemetryHandler.ts","../src/public/createTelemetryHandler.ts","../src/public/createApplicationInsightsTransport.ts","../src/private/createWinstonFormat.ts","../src/public/isRunningInAzure.ts","../src/public/isRunningLocally.ts","../src/public/createWinstonLogger.ts"],"names":["TelemetrySeverity","ApplicationInsightsVersion","isError","SPLAT","level","message","rest","winston"],"mappings":";;;;AAAO,IAAK,iBAAA,qBAAAA,kBAAAA,KAAL;AACL,EAAAA,mBAAA,SAAA,CAAA,GAAU,SAAA;AACV,EAAAA,mBAAA,aAAA,CAAA,GAAc,aAAA;AACd,EAAAA,mBAAA,SAAA,CAAA,GA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',\n Critical = 'Critical',\n}\n\nexport enum ApplicationInsightsVersion {\n V2 = '2.x',\n V3 = '3.x',\n}\n","import { TelemetrySeverity } from '../public/enums';\nimport type { SeverityMapping } from '../public/types';\n\nexport const defaultSeverityMapping: SeverityMapping = {\n error: TelemetrySeverity.Error,\n warn: TelemetrySeverity.Warning,\n info: TelemetrySeverity.Information,\n verbose: TelemetrySeverity.Verbose,\n};\n","/**\n * Ensures that the object returned has a constructor to avoid a {@link TypeError} from the `applicationinsights` library.\n * @param value\n * @returns\n */\nexport const convertNullPrototypeToRegularObject = (value: unknown): unknown => {\n if (value != null && typeof value === 'object' && value.constructor === undefined) {\n return { ...value };\n }\n return value;\n};\n","import { SPLAT } from 'triple-beam';\nimport type { IsError, TelemetryDataException } from '../public/types';\nimport { convertNullPrototypeToRegularObject } from './convertNullPrototypeToRegularObject';\nimport type { WinstonInfo } from './types';\n\nconst extractErrorProperties = (error: Error, ...additionalIgnore: string[]): Record<string, unknown> => {\n const ignore = ['message', 'name', 'stack', ...additionalIgnore];\n const properties: Record<string, unknown> = {};\n for (const key of Object.keys(error) as (keyof Error)[]) {\n if (!ignore.includes(key)) {\n const value = error[key];\n properties[key] = convertNullPrototypeToRegularObject(value);\n }\n }\n return properties;\n};\n\nexport const extractErrorsStep = (info: WinstonInfo, isError: IsError): TelemetryDataException[] => {\n const exceptions: TelemetryDataException[] = [];\n\n if (isError(info)) {\n exceptions.push({\n exception: info,\n properties: extractErrorProperties(info, 'level'),\n });\n }\n\n const splat = info[SPLAT];\n if (splat != null) {\n for (const item of splat) {\n if (isError(item)) {\n exceptions.push({\n exception: item,\n properties: extractErrorProperties(item),\n });\n }\n }\n }\n\n return exceptions;\n};\n","import { SPLAT } from 'triple-beam';\nimport type { WinstonInfo } from './types';\n\nconst getMessageAsString = (info: WinstonInfo) => {\n let messageAsString = String(info.message);\n const splat = info[SPLAT] ?? [];\n const meta = splat[0] as { message?: unknown };\n\n if (meta?.message !== undefined) {\n const expectedSuffix = ` ${meta.message}`;\n if (messageAsString.endsWith(expectedSuffix)) {\n messageAsString = messageAsString.slice(0, -expectedSuffix.length);\n }\n }\n\n return { messageAsString, splat };\n};\n\nconst extractMessageStepInternal = (info: WinstonInfo): string => {\n const { messageAsString, splat } = getMessageAsString(info);\n const strings = splat.filter((x) => typeof x === 'string');\n return [messageAsString, ...strings].join(' ');\n};\n\nexport const extractMessageStep = (info: WinstonInfo): string => {\n const result = extractMessageStepInternal(info);\n return result;\n};\n","export const isPlainObject = (obj: unknown): obj is Record<string, unknown> => {\n if (obj == null || typeof obj !== 'object') {\n return false;\n }\n const proto = Object.getPrototypeOf(obj);\n return proto === Object.prototype || proto === null;\n};\n","import { SPLAT } from 'triple-beam';\nimport type { IsError, TelemetryDataProperties } from '../public/types';\nimport { convertNullPrototypeToRegularObject } from './convertNullPrototypeToRegularObject';\nimport { isPlainObject } from './isPlainObject';\nimport type { WinstonInfo } from './types';\n\nconst extractNonSymbolProps = (obj: Record<string | symbol, unknown>): Record<string, unknown> | null => {\n const entries = Object.entries(obj);\n if (entries.length === 0) {\n return null;\n }\n\n const result: Record<string, unknown> = {};\n for (const [key, value] of entries) {\n result[key] = convertNullPrototypeToRegularObject(value);\n }\n return result;\n};\n\nconst extractDefaultMeta = (info: WinstonInfo, isError: IsError): Record<string, unknown> | null => {\n if (isError(info)) {\n const { level, message, ...rest } = info;\n return extractNonSymbolProps(rest);\n }\n const { level, name, message, stack, cause, ...rest } = info;\n return extractNonSymbolProps(rest);\n};\n\nexport const extractPropertiesStep = (info: WinstonInfo, isError: IsError = (x) => x instanceof Error): TelemetryDataProperties => {\n const defaultMeta = extractDefaultMeta(info, isError);\n\n const splat = info[SPLAT];\n if (splat == null) {\n return defaultMeta ?? {};\n }\n\n const nonErrorItems = splat.filter((item) => !isError(item));\n const firstObject = nonErrorItems[0];\n if (firstObject != null && isPlainObject(firstObject)) {\n return { ...defaultMeta, ...firstObject };\n }\n return defaultMeta ?? {};\n};\n","import { TelemetrySeverity } from '../public/enums';\nimport type { SeverityMapping, WinstonLevels } from '../public/types';\nimport type { WinstonInfo } from './types';\n\nexport const extractSeverityStep = (info: WinstonInfo, severityMapping: SeverityMapping, levels?: WinstonLevels): TelemetrySeverity => {\n const directMapping = severityMapping[info.level];\n if (directMapping != null) {\n return directMapping;\n }\n\n if (levels != null) {\n const currentPriority = levels[info.level];\n\n if (currentPriority != null) {\n const sortedLevels = Object.entries(levels)\n .map((x) => ({ levelName: x[0], priority: x[1] }))\n .filter((x) => currentPriority < x.priority)\n .sort((a, b) => a.priority - b.priority);\n\n for (const { levelName } of sortedLevels) {\n const severity = severityMapping[levelName];\n if (severity) {\n return severity;\n }\n }\n }\n }\n\n return TelemetrySeverity.Verbose;\n};\n","export const isError = (item: unknown): item is Error => item instanceof Error;\n","import TransportStream from 'winston-transport';\nimport type { TelemetryDataException, TelemetryHandler, WinstonLevels } from '../public/types';\nimport { defaultSeverityMapping } from './consts';\nimport { extractErrorsStep } from './extractErrorsStep';\nimport { extractMessageStep } from './extractMessageStep';\nimport { extractPropertiesStep } from './extractPropertiesStep';\nimport { extractSeverityStep } from './extractSeverityStep';\nimport { isError } from './isError';\nimport type { ApplicationInsightsTransportOptions, RequiredOptions, WinstonInfo } from './types';\n\nexport class ApplicationInsightsTransport extends TransportStream {\n private readonly telemetryHandler: TelemetryHandler;\n private readonly options: RequiredOptions;\n\n public levels?: WinstonLevels;\n\n constructor(options: ApplicationInsightsTransportOptions) {\n super({\n level: options.level,\n });\n this.options = {\n telemetryHandler: options.telemetryHandler,\n severityMapping: options.severityMapping ?? defaultSeverityMapping,\n isError: options.isError ?? isError,\n traceFilter: options.traceFilter ?? (() => true),\n exceptionFilter: options.exceptionFilter ?? (() => true),\n };\n this.telemetryHandler = options.telemetryHandler;\n }\n\n public override log(info: WinstonInfo, next: () => void) {\n const exceptions = this.getExceptions(info);\n const trace = this.getTrace(info, exceptions);\n\n this.telemetryHandler.handleTelemetry({\n trace,\n exceptions,\n });\n\n next();\n }\n\n private getTrace(info: WinstonInfo, filteredExceptions: TelemetryDataException[]) {\n const trace = this.extractTrace(info, filteredExceptions);\n if (trace != null && this.options.traceFilter(trace)) {\n return trace;\n }\n return null;\n }\n\n private getExceptions(info: WinstonInfo) {\n const exceptions = extractErrorsStep(info, this.options.isError);\n const filtered = exceptions.filter(this.options.exceptionFilter);\n return filtered;\n }\n\n private extractTrace(info: WinstonInfo, errors: TelemetryDataException[]) {\n const shouldSendOnlyException = errors.length > 0 && this.options.isError(info);\n\n if (shouldSendOnlyException) {\n return null;\n }\n\n const message = extractMessageStep(info);\n const properties = extractPropertiesStep(info, this.options.isError);\n const severity = extractSeverityStep(info, this.options.severityMapping, this.levels);\n\n return {\n message: message,\n properties,\n severity,\n };\n }\n}\n","import type { ExceptionTelemetry, TraceTelemetry } from 'applicationinsightsv2/out/Declarations/Contracts';\nimport { TelemetrySeverity } from '../public/enums';\nimport type { ITelemetryClientV2 } from '../public/ITelemetryClientV2';\nimport type { TelemetryData, TelemetryHandler } from '../public/types';\n\n// From application insights\n// Declare locally to avoid importing the library\nenum SeverityLevel {\n Verbose = 0,\n Information = 1,\n Warning = 2,\n Error = 3,\n Critical = 4,\n}\n\nexport interface ApplicationInsightsV2TelemetryHandlerOptions {\n client: ITelemetryClientV2;\n}\n\nexport class ApplicationInsightsV2TelemetryHandler implements TelemetryHandler {\n private readonly client: ITelemetryClientV2;\n private readonly severityMapping: Record<TelemetrySeverity, SeverityLevel> = {\n [TelemetrySeverity.Verbose]: SeverityLevel.Verbose,\n [TelemetrySeverity.Information]: SeverityLevel.Information,\n [TelemetrySeverity.Warning]: SeverityLevel.Warning,\n [TelemetrySeverity.Error]: SeverityLevel.Error,\n [TelemetrySeverity.Critical]: SeverityLevel.Critical,\n };\n\n constructor(options: ApplicationInsightsV2TelemetryHandlerOptions) {\n this.client = options.client;\n }\n\n public handleTelemetry(telemetry: TelemetryData): void {\n if (telemetry.trace != null) {\n const trace: TraceTelemetry = {\n message: telemetry.trace.message,\n severity: this.mapSeverity(telemetry.trace.severity),\n properties: telemetry.trace.properties,\n };\n this.client.trackTrace(trace);\n }\n\n for (const error of telemetry.exceptions) {\n const exceptionTelemetry = {\n exception: error.exception,\n properties: error.properties,\n } satisfies ExceptionTelemetry;\n\n this.client.trackException(exceptionTelemetry);\n }\n }\n\n private mapSeverity(severity: TelemetrySeverity): SeverityLevel {\n return this.severityMapping[severity];\n }\n}\n","import type { ExceptionTelemetry, TraceTelemetry } from 'applicationinsightsv3';\nimport { KnownSeverityLevel } from 'applicationinsightsv3';\nimport { TelemetrySeverity } from '../public/enums';\nimport type { ITelemetryClientV3 } from '../public/ITelemetryClientV3';\nimport type { TelemetryData, TelemetryHandler } from '../public/types';\n\nexport interface ApplicationInsightsV3TelemetryHandlerOptions {\n client: ITelemetryClientV3;\n}\n\nexport class ApplicationInsightsV3TelemetryHandler implements TelemetryHandler {\n private readonly client: ITelemetryClientV3;\n private readonly severityMapping: Record<TelemetrySeverity, KnownSeverityLevel> = {\n [TelemetrySeverity.Verbose]: KnownSeverityLevel.Verbose,\n [TelemetrySeverity.Information]: KnownSeverityLevel.Information,\n [TelemetrySeverity.Warning]: KnownSeverityLevel.Warning,\n [TelemetrySeverity.Error]: KnownSeverityLevel.Error,\n [TelemetrySeverity.Critical]: KnownSeverityLevel.Critical,\n };\n\n constructor(options: ApplicationInsightsV3TelemetryHandlerOptions) {\n this.client = options.client;\n }\n\n public handleTelemetry(telemetry: TelemetryData): void {\n if (telemetry.trace != null) {\n const trace: TraceTelemetry = {\n message: telemetry.trace.message,\n severity: this.mapSeverity(telemetry.trace.severity),\n properties: telemetry.trace.properties,\n };\n this.client.trackTrace(trace);\n }\n\n for (const error of telemetry.exceptions) {\n const exceptionTelemetry = {\n exception: error.exception,\n properties: error.properties,\n } satisfies ExceptionTelemetry;\n\n this.client.trackException(exceptionTelemetry);\n }\n }\n\n private mapSeverity(severity: TelemetrySeverity): KnownSeverityLevel {\n return this.severityMapping[severity];\n }\n}\n","import { ApplicationInsightsV2TelemetryHandler } from '../private/ApplicationInsightsV2TelemetryHandler';\nimport { ApplicationInsightsV3TelemetryHandler } from '../private/ApplicationInsightsV3TelemetryHandler';\nimport { ApplicationInsightsVersion } from './enums';\nimport type { CreateTelemetryHandlerOptions, TelemetryHandler } from './types';\n\nexport const createTelemetryHandler = (options: CreateTelemetryHandlerOptions): TelemetryHandler => {\n switch (options.version) {\n case ApplicationInsightsVersion.V2: {\n return new ApplicationInsightsV2TelemetryHandler({\n client: options.client,\n });\n }\n case ApplicationInsightsVersion.V3: {\n return new ApplicationInsightsV3TelemetryHandler({\n client: options.client,\n });\n }\n default: {\n return options.telemetryHandler;\n }\n }\n};\n","import type TransportStream from 'winston-transport';\nimport { ApplicationInsightsTransport } from '../private/ApplicationInsightsTransport';\nimport { createTelemetryHandler } from './createTelemetryHandler';\nimport type { CreateApplicationInsightsTransportOptions } from './types';\n\nexport const createApplicationInsightsTransport = (options: CreateApplicationInsightsTransportOptions): TransportStream => {\n const telemetryHandler = createTelemetryHandler(options);\n\n const transport = new ApplicationInsightsTransport({\n telemetryHandler,\n severityMapping: options.severityMapping,\n exceptionFilter: options.exceptionFilter,\n traceFilter: options.traceFilter,\n isError: options.isError,\n level: options.level,\n });\n\n return transport;\n};\n","import type { ColorizeOptions, Format, TimestampOptions, TransformableInfo } from 'logform';\nimport { MESSAGE } from 'triple-beam';\nimport winston from 'winston';\n\n/**\n * Converts escaped ANSI color codes back to actual ANSI escape sequences.\n * Specifically converts `\\\\u001b` (escaped) to `\\u001b` (ESC character, ^[ or 0x1B).\n * @see https://github.com/winstonjs/logform#colorize\n */\nconst unescapeColorCodes = (info: TransformableInfo) => {\n const message = info[MESSAGE] as string;\n return message.replaceAll(/\\\\u001b/g, '\\u001b');\n};\n\nconst unescapeColorCodesFormat = () => winston.format.printf(unescapeColorCodes);\n\nexport type CreateWinstonFormatOptions =\n | Format[]\n | {\n output: 'json' | 'simple';\n errors: boolean | { stack?: boolean };\n timestamp: boolean | TimestampOptions;\n colorize: boolean | ColorizeOptions;\n };\n\nexport const createWinstonFormat = (config: CreateWinstonFormatOptions): Format => {\n if (Array.isArray(config)) {\n return winston.format.combine(...config);\n }\n\n const formats: Format[] = [];\n\n if (config.timestamp === true) {\n formats.push(winston.format.timestamp());\n } else if (typeof config.timestamp === 'object') {\n formats.push(winston.format.timestamp(config.timestamp));\n }\n\n if (config.errors === true) {\n formats.push(winston.format.errors({ stack: true }));\n } else if (typeof config.errors === 'object') {\n formats.push(winston.format.errors(config.errors));\n }\n\n if (config.colorize === true) {\n formats.push(winston.format.colorize({ all: true }));\n } else if (typeof config.colorize === 'object') {\n formats.push(winston.format.colorize(config.colorize));\n }\n\n if (config.output === 'simple') {\n formats.push(winston.format.simple());\n }\n if (config.output === 'json') {\n formats.push(winston.format.json());\n\n if (config.colorize === true || typeof config.colorize === 'object') {\n formats.push(unescapeColorCodesFormat());\n }\n }\n\n return winston.format.combine(...formats);\n};\n","import { env } from 'node:process';\n\nexport const isRunningInAzure = () => {\n return env.WEBSITE_INSTANCE_ID !== undefined;\n};\n","import { isRunningInAzure } from './isRunningInAzure';\n\nexport const isRunningLocally = () => {\n return !isRunningInAzure();\n};\n","import winston from 'winston';\nimport type TransportStream from 'winston-transport';\nimport { type CreateWinstonFormatOptions, createWinstonFormat } from '../private/createWinstonFormat';\nimport { createApplicationInsightsTransport } from './createApplicationInsightsTransport';\nimport { createTelemetryHandler } from './createTelemetryHandler';\nimport { isRunningLocally } from './isRunningLocally';\nimport type { CreateWinstonLoggerOptions } from './types';\n\nexport const createWinstonLogger = (options: CreateWinstonLoggerOptions): winston.Logger => {\n const { severityMapping, exceptionFilter, traceFilter, isError, ...rest } = options.insights;\n\n const telemetryHandler = createTelemetryHandler(rest);\n\n const transports: TransportStream[] = [];\n\n const consoleEnabled = options.winston?.console?.enabled ?? isRunningLocally();\n if (consoleEnabled) {\n let consoleFormatConfig: CreateWinstonFormatOptions | undefined;\n\n if (Array.isArray(options.winston?.console?.format)) {\n consoleFormatConfig = options.winston.console.format;\n } else {\n const userFormat = options.winston?.console?.format ?? {};\n consoleFormatConfig = {\n output: userFormat.output ?? 'json',\n timestamp: userFormat.timestamp ?? true,\n errors: userFormat.errors ?? { stack: true },\n colorize: userFormat.colorize ?? true,\n };\n }\n\n const consoleFormat = createWinstonFormat(consoleFormatConfig);\n\n transports.push(\n new winston.transports.Console({\n format: consoleFormat,\n level: options.winston?.console?.level,\n stderrLevels: ['error', 'crit', 'alert', 'emerg'],\n consoleWarnLevels: ['warn', 'warning'],\n }),\n );\n }\n\n // Insights transport\n const insightsEnabled = options.winston?.insights?.enabled ?? true;\n if (insightsEnabled) {\n const transport = createApplicationInsightsTransport({\n telemetryHandler,\n severityMapping,\n exceptionFilter,\n traceFilter,\n isError,\n level: options.winston?.insights?.level,\n });\n transports.push(transport);\n }\n\n // Merge defaults with logger-level options\n const level = options.winston?.defaults?.level ?? 'info';\n const levels = options.winston?.levels ?? winston.config.npm.levels;\n const globalFormats = options.winston?.defaults?.format ?? [];\n\n const format = winston.format.combine(...globalFormats);\n\n return winston.createLogger({\n ...options.winston?.options,\n level,\n levels,\n format,\n transports,\n defaultMeta: options.winston?.defaults?.defaultMeta,\n });\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shellicar/winston-azure-application-insights",
3
- "version": "6.0.0",
3
+ "version": "6.0.2-preview.1",
4
4
  "private": false,
5
5
  "description": "Azure Application Insights transport for Winston",
6
6
  "type": "module",
@@ -40,24 +40,23 @@
40
40
  ],
41
41
  "license": "MIT",
42
42
  "devDependencies": {
43
- "@types/node": "^24.3.0",
43
+ "@types/node": "^24.9.1",
44
44
  "@types/triple-beam": "^1.3.5",
45
- "@vitest/coverage-v8": "^3.2.4",
45
+ "@vitest/coverage-v8": "^4.0.2",
46
46
  "logform": "^2.7.0",
47
- "terser": "^5.43.1",
47
+ "terser": "^5.44.0",
48
48
  "testdouble": "^3.20.2",
49
49
  "triple-beam": "^1.4.1",
50
50
  "tsup": "^8.5.0",
51
- "tsx": "^4.20.5",
52
- "typescript": "^5.9.2",
53
- "vitest": "^3.2.4",
54
- "winston": "^3.17.0",
51
+ "tsx": "^4.20.6",
52
+ "typescript": "^5.9.3",
53
+ "vitest": "^4.0.2",
54
+ "winston": "^3.18.3",
55
55
  "winston-transport": "^4.9.0"
56
56
  },
57
57
  "optionalDependencies": {
58
58
  "applicationinsightsv2": "npm:applicationinsights@^2",
59
- "applicationinsightsv3": "npm:applicationinsights@^3",
60
- "applicationinsightsv34": "npm:applicationinsights@^3.4"
59
+ "applicationinsightsv3": "npm:applicationinsights@^3"
61
60
  },
62
61
  "bugs": {
63
62
  "url": "https://github.com/shellicar/winston-azure-application-insights/issues"