Installations
npm install logzio-nodejs
Score
55.7
Supply Chain
97.8
Quality
83
Maintenance
100
Vulnerability
99.6
License
Developer
logzio
Developer Guide
Module System
CommonJS
Min. Node Version
>= 14.0.0
Typescript Support
Yes
Node Version
17.9.1
NPM Version
8.11.0
Statistics
36 Stars
147 Commits
38 Forks
22 Watching
27 Branches
52 Contributors
Updated on 16 Sept 2024
Bundle Size
45.07 kB
Minified
17.15 kB
Minified + Gzipped
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
74,765,774
Last day
5%
11,043
Compared to previous day
Last week
6.6%
58,760
Compared to previous week
Last month
-26.4%
268,060
Compared to previous month
Last year
-65.2%
16,820,320
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
logzio-nodejs
NodeJS logger for Logz.io. The logger stashes the log messages you send into an array which is sent as a bulk once it reaches its size limit (100 messages) or time limit (10 sec) in an async fashion. It contains a simple retry mechanism which upon connection reset (server side) or client timeout, wait a bit (default interval of 2 seconds), and try this bulk again. It does not block other messages from being accumulated and sent (async). The interval increases by a factor of 2 between each retry until it reaches the maximum allowed attempts (3).
By default, any error is logged to the console. This can be changed by supplying a callback function.
Before you begin you will need:
Nodejs
with version 14.x or above
Sample usage
1var logger = require('logzio-nodejs').createLogger({ 2 token: '__YOUR_ACCOUNT_TOKEN__', 3 type: 'YourLogType' // OPTIONAL (If none is set, it will be 'nodejs') 4}); 5 6 7// sending text 8logger.log('This is a log message'); 9 10// sending an object 11var obj = { 12 message: 'Some log message', 13 param1: 'val1', 14 param2: 'val2' 15}; 16logger.log(obj);
Note: If logzio-js is used as part of a serverless service (AWS Lambda, Azure Functions, Google Cloud Functions, etc.), add logger.sendAndClose()
at the end of the run. For example sync Lambda and async Lambda
Options
- token Mandatory. Your account token. Look it up in the Device Config tab in Logz.io
- type - Log type. Help classify logs into different classifications
- protocol -
http
,https
orudp
. Default:http
- host - Destination host name. Default:
listener.logz.io
- port - Destination port. Default port depends on protocol. For
udp
default port is5050
, forhttp
is8070
and8071
is forhttps
- sendIntervalMs - Time in milliseconds to wait between retry attempts. Default:
2000
(2 sec) - bufferSize - The maximum number of messages the logger will accumulate before sending them all as a bulk. Default:
100
. - numberOfRetries - The maximum number of retry attempts. Default:
3
- debug - Should the logger print debug messages to the console? Default:
false
- callback - A callback function called when an unrecoverable error has occured in the logger. The function API is: function(err) - err being the Error object.
- timeout - The read/write/connection timeout in milliseconds.
- addTimestampWithNanoSecs - Add a timestamp with nano seconds granularity. This is needed when many logs are sent in the same millisecond, so you can properly order the logs in kibana. The added timestamp field will be
@timestamp_nano
Default:false
- compress - If true the the logs are compressed in gzip format. Default:
false
- internalLogger - set internal logger that supports the function log. Default: console.
- extraFields - Adds your own custom fields to each log. Add in JSON Format, for example:
extraFields : { field_1: "val_1", field_2: "val_2" , ... }
.
Using UDP
A few notes are worth mentioning regarding the use of the UDP protocol:
- UDP has some limitations, and therefore it is not the recommended protocol:
- There is no guarantee that the logs have been received.
- UDP can't take advantage of the bulk API, so performance is sub-optimal.
- When using UDP, each message is sent separately, and not using the bulk API. This means that the meaning of
bufferSize
is slightly different in this case. The messages will still be sent separately, but the logger will wait for the buffer to reach the size specified before sending out all the messages. If you want each message to be sent out immediately, then setbufferSize = 1
.
Build and test locally
- Clone the repository:
1git clone https://github.com/logzio/logzio-nodejs.git 2cd logzio-nodejs
- Build and run tests:
1npm install 2npm test
Update log
2.1.8
- Make
User-Agent
not optional and add the version to it.
2.1.7
- upgrade
axios
tov1.6.4
(contributed by @gcagle3)
2.1.6
- Test node versions
14-20
- upgrade
axios
tov1.6.0
(contributed by @gcagle3)
2.1.5
- Add sourceIP as a new field to each log
2.1.4
- Replace from request to axios
2.0.4
- Add parameter to manage User-agent
2.0.3
- Add verbose logging to use in Azure serverless function
2.0.2
- Updated required fields for typescript
2.0.1
- Fixed sorting by nanosec-timestamp
- Added option to log string with an object
- Updated Typescript declaration for optional dependencies
2.0.0
- Added support for TypeScript
- End of support for node 6
- Upgrade dependencies due to security vulnerabilities
Expand to check old versions
1.0.4 - 1.0.6
- Upgrade dependencies due to security vulnerabilities
1.0.3
- Added the bulk to the callback in case the send failed
1.0.2
- Handle no Error code on bad requests
1.0.1
- ES6
- Support node greater than node 6
- Added gzip compress option
- Added internal logger option
0.4.14
- UDP callback bug fix + tests
- UDP close connection bug fix + tests
- ESLint
0.4.12
- Updated ability to add custom port
0.4.6
- Updated moment (v2.19.3) and request (v2.81.0) packages
0.4.4
@timestamp
and@timestamp_nano
will no longer be overriden given a custom value by the user.
0.4.3
- Add the
@timestamp
field to the logs on the client's machine (and not when it reaches the server)
0.4.1
- Updated
request
dependency to 2.75.0
0.4.0
- Fixed issue #12 - added support for UDP
- Minor refactorings
0.3.10
- Fixed issue #17 - sendAndClose() wasn't actually closing the timer
0.3.9
- Added option to add a timestamp with nano second granularity
0.3.8
- Updated listener url
- Added
sendAndClose()
method which immediately sends the queued messages and clears the global timer - Added option to supress error messages
0.3.6
- Fixed URL for github repository in package.json
0.3.5
- Bug fix : upon retry (in case of network error), the message gets sent forever
0.3.4
- Bug fix :
jsonToString()
was throwing an error in the catch()block
0.3.2
- Enhancement : Added option to attach extra fields to each log in a specific instance of the logger.
0.3.1
- Bug fix : When calling
log
with a string parameter, the object isn't constructed properly.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
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: Apache License 2.0: LICENSE:0
Reason
Found 16/29 approved changesets -- score normalized to 5
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:8: update your workflow using https://app.stepsecurity.io/secureworkflow/logzio/logzio-nodejs/npm-publish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/logzio/logzio-nodejs/npm-publish.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/logzio/logzio-nodejs/npm-publish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test-nodejs.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/logzio/logzio-nodejs/test-nodejs.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test-nodejs.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/logzio/logzio-nodejs/test-nodejs.yml/master?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/npm-publish.yml:13
- Warn: npmCommand not pinned by hash: .github/workflows/test-nodejs.yml:25
- Info: 0 out of 4 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 third-party GitHubAction dependencies pinned
- Info: 1 out of 3 npmCommand dependencies pinned
Reason
2 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/npm-publish.yml:1
- Warn: no topLevel permission defined: .github/workflows/test-nodejs.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
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
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
20 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-8hc4-vh64-cxmj
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-2j2x-2gpw-g8fm
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 19 are checked with a SAST tool
Score
3.5
/10
Last Scanned on 2024-11-18
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 MoreOther packages similar to logzio-nodejs
logzio-nodejs-metrics
A nodejs implementation for sending metrics to Logz.io
logzio-nodejs-metrics-sdk
Logz.io node.js metrics Exporter allows user to send collected metrics to the Logz.io using OpenTelemetry SDK
winston-logzio
A winston transport wrapper for logzio
yotamloe-nodejs
A nodejs implementation for sending logs to Logz.IO cloud service Copy of logzio-nodejs