{"id":23066889,"url":"https://github.com/dvsa/azure-logger","last_synced_at":"2025-10-26T11:09:00.995Z","repository":{"id":40384303,"uuid":"241630462","full_name":"dvsa/azure-logger","owner":"dvsa","description":null,"archived":false,"fork":false,"pushed_at":"2024-11-18T10:12:22.000Z","size":1936,"stargazers_count":0,"open_issues_count":1,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-18T11:35:59.390Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dvsa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-19T13:36:40.000Z","updated_at":"2024-11-18T10:12:26.000Z","dependencies_parsed_at":"2023-11-14T13:27:55.803Z","dependency_job_id":"fcca4834-1a0b-40d0-92d8-36eb83ceaaa9","html_url":"https://github.com/dvsa/azure-logger","commit_stats":{"total_commits":61,"total_committers":13,"mean_commits":"4.6923076923076925","dds":0.7377049180327868,"last_synced_commit":"2de2e5da37c1970bc619043ccbf1b0ce5fe0604d"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvsa%2Fazure-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvsa%2Fazure-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvsa%2Fazure-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvsa%2Fazure-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dvsa","download_url":"https://codeload.github.com/dvsa/azure-logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229910956,"owners_count":18143229,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-16T05:15:27.777Z","updated_at":"2025-10-26T11:09:00.935Z","avatar_url":"https://github.com/dvsa.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Azure Logger\n\nWinston Logger with a custom Azure Application Insights Transport\n\n### Logging levels\n* critical\n* error\n* warning\n* event\n* request\n* dependency\n* security\n* audit\n* info\n* debug\n\n## Installation\n\nIf using npm:\n```\nnpm install @dvsa/azure-logger\n```\nor if using Yarn\n```\nyarn add @dvsa/azure-logger\n```\n\nSpecify the environment variables in a .env file, for example\n```\nLOG_LEVEL=event\n\nNODE_ENV=development\n\nAPPLICATIONINSIGHTS_CONNECTION_STRING={APPLICATION_INSIGHTS_CONNECTION_STRING}\n```\n## Example Use:\n\n1) Create a file logger.ts and export the azure logger from it, instantiating it with the project and component names.\n```typescript\nimport { Logger } from '@dvsa/azure-logger';\n\nexport default new Logger('ftts', 'ftts-location-api');\n```\n\n2) For Azure Functions, two wrappers are provided to enable auto correlation of all logs and telemetry including external requests and dependencies.\nFor HTTP triggers use the `httpTriggerContextWrapper` with req passed in. Use `nonHttpTriggerContextWrapper` for all other trigger types.\nFor example, wrap a time trigger function in your function index file like so:\n```typescript\nimport { nonHttpTriggerContextWrapper } from '@dvsa/azure-logger';\nimport { AzureFunction, Context } from '@azure/functions';\n\nconst myTimeTrigger: AzureFunction = async (): Promise\u003cvoid\u003e =\u003e {\n    // do something\n};\n\nexport default async (context: Context): Promise\u003cvoid\u003e =\u003e nonHttpTriggerContextWrapper(myTimeTrigger, context);\n```\n\nRequest and dependency log methods are still provided for manual tracing if it is needed e.g. for service bus correlation.\nThese require context to be passed in to fetch the correct trace ids.\n\n3) Whenever you want to log an item import the logger.ts file.\n```typescript\nimport logger from './logger';\n\nfunction getData(): void {\n    try {\n        // Do calculations\n    } catch(error) {\n        logger.error(error);\n    }\n}\n```\n\n## APPLICATIONINSIGHTS_CONNECTION_STRING\n\nWhen using an Azure function app the following environment variable must be present and contain the connection string for the application insights instance you wish to use.\n  \nAPPLICATIONINSIGHTS_CONNECTION_STRING\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdvsa%2Fazure-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdvsa%2Fazure-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdvsa%2Fazure-logger/lists"}