How to use the io-functions-commons/dist/src/utils/logging.configureAzureContextTransport function in io-functions-commons

To help you get started, we’ve selected a few io-functions-commons examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github teamdigitale / io-functions / lib / emailnotifications_queue_handler.ts View on Github external
export async function index(
  context: ContextWithBindings
): Promise {
  const stopProcessing = undefined;
  const logLevel = isProduction ? "info" : "debug";
  configureAzureContextTransport(context, winston, logLevel);

  winston.debug(`STARTED|${context.invocationId}`);

  winston.debug(
    `EmailNotificationsHandlerIndex|Dequeued email notification|${JSON.stringify(
      context.bindings
    )}`
  );

  // since this function gets triggered by a queued message that gets
  // deserialized from a json object, we must first check that what we
  // got is what we expect.
  const errorOrNotificationEvent = NotificationEvent.decode(
    context.bindings.notificationEvent
  );
  if (isLeft(errorOrNotificationEvent)) {
github teamdigitale / io-functions / lib / compute_visible_services.ts View on Github external
export async function index(context: Context): Promise {
  const logLevel = isProduction ? "info" : "debug";
  configureAzureContextTransport(context, winston, logLevel);
  try {
    // iterate over the whole services collection and collect visible services
    const servicesCollectionIterator = await serviceModel.getCollectionIterator();
    const servicesIterator = documentDbUtils.reduceResultIterator(
      servicesCollectionIterator,
      reduceServicesToVisibleServices
    );
    const errorOrVisibleServices = await documentDbUtils.iteratorToValue(
      servicesIterator,
      new StrMap({})
    );
    if (isLeft(errorOrVisibleServices)) {
      winston.error(
        "ComputeVisibleServices|Error computing visible services: %s",
        errorOrVisibleServices.value
      );
github teamdigitale / io-functions / lib / webhook_queue_handler.ts View on Github external
export async function index(
  context: ContextWithBindings
): Promise {
  const logLevel = isProduction ? "info" : "debug";
  configureAzureContextTransport(context, winston, logLevel);

  winston.debug(
    `WebhookNotificationsHandlerIndex|Dequeued webhook notification|${JSON.stringify(
      context.bindings
    )}`
  );

  // since this function gets triggered by a queued message that gets
  // deserialized from a json object, we must first check that what we
  // got is what we expect.
  const errorOrNotificationEvent = NotificationEvent.decode(
    context.bindings.notificationEvent
  );
  if (isLeft(errorOrNotificationEvent)) {
    winston.error(
      `WebhookNotificationsHandler|Fatal! No valid message found in bindings.|${readableReport(
github teamdigitale / io-functions / lib / created_message_queue_handler.ts View on Github external
export async function index(
  context: ContextWithBindings
): Promise {
  const logLevel = isProduction ? "info" : "debug";
  configureAzureContextTransport(context, winston, logLevel);

  winston.debug(
    `CreatedMessageQueueHandler|queueMessage|${JSON.stringify(
      context.bindings
    )}`
  );

  // since this function gets triggered by a queued message that gets
  // deserialized from a json object, we must first check that what we
  // got is what we expect.
  const errorOrCreatedMessageEvent = CreatedMessageEvent.decode(
    context.bindings.createdMessage
  );
  if (isLeft(errorOrCreatedMessageEvent)) {
    winston.error(
      `CreatedMessageQueueHandler|Fatal! No valid message found in bindings.|${readableReport(
github teamdigitale / io-functions / lib / admin_api.ts View on Github external
export function index(context: Context): void {
  const logLevel = isProduction ? "info" : "debug";
  configureAzureContextTransport(context, winston, logLevel);
  setAppContext(app, context);
  azureFunctionHandler(context);
}
github teamdigitale / io-functions / lib / public_api_v1.ts View on Github external
export function index(context: Context): void {
  const logLevel = isProduction ? "info" : "debug";
  configureAzureContextTransport(context, winston, logLevel);
  setAppContext(app, context);
  azureFunctionHandler(context);
}
github teamdigitale / io-functions / lib / queue_monitor.ts View on Github external
export function index(context: Context): Promise> {
  const logLevel = isProduction ? "info" : "debug";
  configureAzureContextTransport(context, winston, logLevel);
  return Promise.all(
    [
      EMAIL_NOTIFICATION_QUEUE_NAME,
      WEBHOOK_NOTIFICATION_QUEUE_NAME,
      MESSAGE_QUEUE_NAME
    ].map(async queueName => {
      (await getQueueMetadata(queueService, queueName)).bimap(
        error =>
          winston.error("Error in QueueMonitor: %s (%s)", error, queueName),
        result => {
          winston.debug(
            "Queue '%s' length is: %d",
            queueName,
            result.approximateMessageCount
          );
          appInsightsClient.trackMetric({
github teamdigitale / io-functions / lib / profile_events_queue_handler.ts View on Github external
export async function index(
  context: ContextWithBindings,
  event: IProfileCreatedEvent | IProfileUpdatedEvent
): Promise {
  const logLevel = isProduction ? "info" : "debug";
  configureAzureContextTransport(context, winston, logLevel);

  winston.debug(
    "ProfileEventsQueueHandler|Received event=%s",
    JSON.stringify(event)
  );

  const isInboxEnabled = event.newProfile.is_inbox_enabled === true;
  const isProfileCreated = event.kind === "ProfileCreatedEvent";
  const hasOldProfileWithInboxDisabled =
    event.kind === "ProfileUpdatedEvent" &&
    event.oldProfile.is_inbox_enabled === false;

  const hasJustEnabledInbox =
    isInboxEnabled && (isProfileCreated || hasOldProfileWithInboxDisabled);

  const appInsightsClient = getCustomTelemetryClient(
github teamdigitale / io-functions / lib / openapi.ts View on Github external
export function index(context: Context): void {
  const logLevel = isProduction ? "info" : "debug";
  configureAzureContextTransport(context, winston, logLevel);
  setAppContext(app, context);
  azureFunctionHandler(context);
}

io-functions-commons

Common code for Azure functions

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis

Similar packages