1.1.1 • Published 6 days ago

@azure/logger v1.1.1

Weekly downloads
301,358
License
MIT
Repository
github
Last release
6 days ago

Azure Logger library for JS

The @azure/logger package can be used to enable logging in the Azure SDKs for JavaScript.

Logging can be enabled for the Azure SDK in the following ways:

  • Setting the AZURE_LOG_LEVEL environment variable
  • Calling setLogLevel imported from "@azure/logger"
  • Calling enable() on specific loggers
  • Using the DEBUG environment variable.

Note that AZURE_LOG_LEVEL, if set, takes precedence over DEBUG. Only use DEBUG without specifying AZURE_LOG_LEVEL or calling setLogLevel.

Getting started

Installation

Install this library using npm as follows

npm install @azure/logger

Key Concepts

The @azure/logger package supports the following log levels specified in order of most verbose to least verbose:

  • verbose
  • info
  • warning
  • error

When setting a log level, either programmitcally or via the AZURE_LOG_LEVEL environment variable, any logs that are written using a log level equal to or less than the one you choose will be emitted.

For example, setting the log level to warning will cause all logs that have the log level warning or error to be emitted.

Examples

Example 1 - basic usage

const { EventHubClient } = require('@azure/event-hubs');

const logger = require('@azure/logger');
logger.setLogLevel('info');

// operations will now emit info, warning, and error logs
const client = new EventHubClient(/* params */);
client.getPartitionIds()
  .then(ids => { /* do work */ })
  .catch(e => { /* do work */ });
});

Example 2 - redirect log ouput

const { AzureLogger, setLogLevel } = require("@azure/logger");

setLogLevel("verbose");

// override logging to output to console.log (default location is stderr)
AzureLogger.log = (...args) => {
  console.log(...args);
};

Using AzureLogger, it is possible to redirect the logging output from the Azure SDKs by overriding the AzureLogger.log method. This may be useful if you want to redirect logs to a location other than stderr.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

If you'd like to contribute to this library, please read the contributing guide to learn more about how to build and test the code.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Impressions

@argoncs/libraries@azure/event-hubs@azure/identity@azure/template@azure/service-bus@azure/keyvault-keys@azure/keyvault-certificates@project-carbon/shared@cocs/common@everything-registry/sub-chunk-107dw-typescript-codegendw-autorest-typescript@microsoft/vscode-azext-azureutils@nikhlagrwl/identityskyeye-svc-common-utilssstchurazure-storage-blob@marygao/core-lro@marygao/typescript@pietert/cyran@soyjak/utils@preevy/driver-azure@yuantw/ai-language-textapplicationinsightz@arkahna/nx-terraformautorest-typescriptautorest-typescript-compat@autorest/azure-functions-typescript@autorest/common@autorest/system-requirements@autorest/typescript@akadenia/azure@alexok/arm-servicefabric-managedcluster@azure-tools/communication-alpha-ids@azure-tools/communication-domain-verification@azure-tools/communication-recipient-verification@azure-tools/communication-short-codes@azure-tools/communication-tiering@azure-tools/communication-toll-free-verification@azure-rest/ai-content-safety@azure-rest/ai-document-intelligence@azure-rest/ai-document-translator@azure-rest/ai-personalizer@azure-rest/ai-translation-text@azure-rest/ai-vision-image-analysis@azure-rest/arm-appservice@azure-rest/arm-compute@azure-rest/arm-containerservice@azure-rest/arm-network@azure-rest/arm-servicefabric@azure-rest/communication-job-router@azure-rest/communication-messages@azure-rest/confidential-ledger@azure-rest/defender-easm@azure-rest/developer-devcenter@azure-rest/health-insights-cancerprofiling@azure-rest/health-insights-clinicalmatching@azure-rest/health-insights-radiologyinsights@azure-rest/iot-device-update@azure-rest/load-testing@azure-rest/maps-route@azure-tools/datastore@azure-tools/extension@azure-rest/maps-search@azure-rest/openai@azure-rest/purview-account@azure-rest/purview-administration@azure-rest/purview-catalog@azure-rest/purview-datamap@azure-rest/purview-scanning@azure-rest/purview-sharing@azure-rest/purview-workflow@azure-rest/agrifood-farming@azure-rest/ai-anomaly-detector@azure-tools/test-recorder@azure/ai-anomaly-detector@azure/ai-form-recognizer@azure/ai-language-text@azure/app-configuration@azure/ai-metrics-advisor@azure/ai-text-analytics@azure/cognitiveservices-textanalytics@azure/communication-administration@azure/communication-call-automation@azure/communication-calling@azure/communication-calling-effects@azure/communication-chat@azure/communication-email@azure/communication-identity@azure/eventgrid@azure/eventhubs-checkpointstore-blob@azure/eventhubs-checkpointstore-table@azure/iot-modelsrepository@azure/keyvault-admin@azure/functions-authentication-events@azure/keyvault-secrets@azure/maps-search@azure/mixed-reality-authentication@azure/mixed-reality-remote-rendering@azure/web-pubsub@azure/web-pubsub-client-protobuf
1.1.1

8 days ago

1.1.0

15 days ago

1.0.4

1 year ago

1.0.3

2 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

4 years ago

1.0.0-preview.1

4 years ago