Installations
npm install @dvsa/azure-logger
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
20.15.0
NPM Version
10.7.0
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (99.04%)
JavaScript (0.96%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
dvsa
Download Statistics
Total Downloads
47,183
Last Day
4
Last Week
21
Last Month
78
Last Year
1,286
GitHub Statistics
74 Commits
3 Forks
5 Watching
18 Branches
10 Contributors
Bundle Size
651.65 kB
Minified
168.41 kB
Minified + Gzipped
Package Meta Information
Latest Version
7.0.3
Package Id
@dvsa/azure-logger@7.0.3
Unpacked Size
110.09 kB
Size
19.49 kB
File Count
61
NPM Version
10.7.0
Node Version
20.15.0
Publised On
18 Nov 2024
Total Downloads
Cumulative downloads
Total Downloads
47,183
Last day
-33.3%
4
Compared to previous day
Last week
23.5%
21
Compared to previous week
Last month
20%
78
Compared to previous month
Last year
-50.3%
1,286
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Azure Logger
Winston Logger with a custom Azure Application Insights Transport
Logging levels
- critical
- error
- warning
- event
- request
- dependency
- security
- audit
- info
- debug
Installation
If using npm:
npm install @dvsa/azure-logger
or if using Yarn
yarn add @dvsa/azure-logger
Specify the environment variables in a .env file, for example
LOG_LEVEL=event
NODE_ENV=development
APPLICATIONINSIGHTS_CONNECTION_STRING={APPLICATION_INSIGHTS_CONNECTION_STRING}
Example Use:
- Create a file logger.ts and export the azure logger from it, instantiating it with the project and component names.
1import { Logger } from '@dvsa/azure-logger'; 2 3export default new Logger('ftts', 'ftts-location-api');
- For Azure Functions, two wrappers are provided to enable auto correlation of all logs and telemetry including external requests and dependencies.
For HTTP triggers use the
httpTriggerContextWrapper
with req passed in. UsenonHttpTriggerContextWrapper
for all other trigger types. For example, wrap a time trigger function in your function index file like so:
1import { nonHttpTriggerContextWrapper } from '@dvsa/azure-logger'; 2import { AzureFunction, Context } from '@azure/functions'; 3 4const myTimeTrigger: AzureFunction = async (): Promise<void> => { 5 // do something 6}; 7 8export default async (context: Context): Promise<void> => nonHttpTriggerContextWrapper(myTimeTrigger, context);
Request and dependency log methods are still provided for manual tracing if it is needed e.g. for service bus correlation. These require context to be passed in to fetch the correct trace ids.
- Whenever you want to log an item import the logger.ts file.
1import logger from './logger'; 2 3function getData(): void { 4 try { 5 // Do calculations 6 } catch(error) { 7 logger.error(error); 8 } 9}
APPLICATIONINSIGHTS_CONNECTION_STRING
When 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.
APPLICATIONINSIGHTS_CONNECTION_STRING
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
1 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-c76h-2ccp-4975
Reason
Found 17/19 approved changesets -- score normalized to 8
Reason
1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 2 commits out of 29 are checked with a SAST tool
Score
4
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More