<commit_before>import { Logger, LoggerService } from '@nestjs/common';
import { AppServicePerformanceCounters } from '../../types/app-service-performance-counters';
import * as appInsights from 'applicationinsights';

export class LoggingService extends Logger implements LoggerService {
  private client: appInsights.TelemetryClient;
  constructor() {
    super();
    if (process.env.aiInstrumentationKey) {
      appInsights
        .setup(process.env.aiInstrumentationKey)
        .setAutoDependencyCorrelation(true)
        .setAutoCollectRequests(true)
        .setAutoCollectPerformance(true)
        .setAutoCollectExceptions(true)
        .setAutoCollectDependencies(true)
        .setAutoCollectConsole(true)
        .setUseDiskRetryCaching(true)
        .start();
      setInterval(this.trackAppServicePerformance, 30 * 1000);
      this.client = appInsights.defaultClient;
    }
  }

  public error(message: any, trace?: string, context?: string) {
    super.error(message, trace, context);

    this.trackEvent(context, { trace, message: JSON.stringify(message) });
  }

  public warn(message: any, context?: string) {
    super.warn(message, context);

    const warningId = `/warnings/server/${context}`;

    this.trackEvent(warningId, message);
  }

  public log(message: any, context?: string) {
    super.log(message, context);<commit_msg>add common identifiers to the loggin client. (#4810)<commit_after>import { Logger, LoggerService } from '@nestjs/common';
import { AppServicePerformanceCounters } from '../../types/app-service-performance-counters';
import * as appInsights from 'applicationinsights';

export class LoggingService extends Logger implements LoggerService {
  private client: appInsights.TelemetryClient;
  constructor() {
    super();
    if (process.env.aiInstrumentationKey) {
      appInsights
        .setup(process.env.aiInstrumentationKey)
        .setAutoDependencyCorrelation(true)
        .setAutoCollectRequests(true)
        .setAutoCollectPerformance(true)
        .setAutoCollectExceptions(true)
        .setAutoCollectDependencies(true)
        .setAutoCollectConsole(true)
        .setUseDiskRetryCaching(true)
        .start();
      setInterval(this.trackAppServicePerformance, 30 * 1000);
      this.client = appInsights.defaultClient;
      this.client.commonProperties['hostName'] = process.env.WEBSITE_HOSTNAME;
      this.client.commonProperties['appName'] = process.env.WEBSITE_SITE_NAME;
      this.client.commonProperties['version'] = process.env.VERSION;
    }
  }

  public error(message: any, trace?: string, context?: string) {
    super.error(message, trace, context);

    this.trackEvent(context, { trace, message: JSON.stringify(message) });
  }

  public warn(message: any, context?: string) {
    super.warn(message, context);

    const warningId = `/warnings/server/${context}`;

    this.trackEvent(warningId, message);
  }

  public log(message: any, context?: string) {
    super.log(message, context);
{'fraction_non_alphanumeric': 0.11602951039570758, 'fraction_numerical': 0.0053655264922870555, 'mean_word_length': 3.8901639344262295, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4545346', 'n_tokens_mistral': 869, 'n_tokens_neox': 837, 'n_words': 164}