willmorgan / winston-azure-application-insights

Azure Application Insights transport for Winston
MIT License
6 stars 7 forks source link

winston-transport too old version? #12

Open mharj opened 11 months ago

mharj commented 11 months ago

Hi, just built types for this module but having bit issue on actual winston transport types as version is quite old. (4.6.0 out) Just wondering that maybe this could be as peerDepencendy instead? (i.e. "4.x")

winston-azure-application-insights.d.ts

declare module "winston-azure-application-insights" {
  import type * as appInsights from "applicationinsights";
  import type * as Transport from "winston-transport";
  type AzureApplicationInsightsLoggerProps = {
    client?: appInsights.TelemetryClient;
    insights?: typeof appInsights;
    key?: string;
    sendErrorsAsExceptions?: boolean;
    level?:
      | "debug"
      | "info"
      | "emerg"
      | "alert"
      | "crit"
      | "error"
      | "warning"
      | "warn"
      | "notice"
      | "verbose"
      | "silly";
  } & Transport.TransportStreamOptions;

  export class AzureApplicationInsightsLogger extends Transport {
    constructor(options?: AzureApplicationInsightsLoggerProps);
  }
}
willmorgan commented 10 months ago

Hi there @mharj, I don't have time to maintain this repo at the moment, would you mind PRing in?

willmorgan commented 9 months ago

@mharj I've merged PR and done a slight test update, but still getting issues due to conn string settings not getting picked up out of the environment. Does your PR #13 resolve the above issue, though?

mharj commented 9 months ago

@willmorgan I don't think this PR changes any functionality, just helps on typescript types (and bit on dependenices). We just manually add connection string directly to appInsights as all our setup are very async by nature. Also it's always better to use long format of connection string as some rare cases we can't get short one connecting propely.

bit like this (simplified) ..

export function setupAppInsights() {
    appInsights.setup(process.env.APPLICATIONINSIGHTS_CONNECTION_STRING).setAutoCollectConsole(false, false).start();
    logger.add(
        new AzureApplicationInsightsLogger({
            insights: appInsights,
            level: 'debug',
        }),
    );
}