Gathering detailed insights and metrics for caterpillar
Gathering detailed insights and metrics for caterpillar
Gathering detailed insights and metrics for caterpillar
Gathering detailed insights and metrics for caterpillar
caterpillar-filter
Filter out undesired log levels from your Caterpillar logger stream
caterpillar-human
Turn your Caterpillar logger stream into a beautiful readable format with colors and optional debug information
caterpillar-browser
Use Caterpillar within Web Browsers! (even includes support for colors!)
caterpillar-examples
Examples of different ways [Caterpillar](http://github.com/bevry/caterpillar) can be used.
Caterpillar is the ultimate logging system for Deno, Node.js, and Web Browsers. Log levels are implemented to the RFC standard. Log entries can be filtered and piped to various streams, including coloured output to the terminal, the browser's console, and debug files. You can even write your own transforms.
npm install caterpillar
Typescript
Module System
Min. Node Version
Node Version
NPM Version
82.5
Supply Chain
99.5
Quality
76.2
Maintenance
100
Vulnerability
100
License
TypeScript (98.86%)
JavaScript (1.14%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
NOASSERTION License
401 Stars
199 Commits
14 Forks
14 Watchers
1 Branches
3 Contributors
Updated on Jul 03, 2025
Latest Version
8.2.0
Package Id
caterpillar@8.2.0
Unpacked Size
232.18 kB
Size
33.03 kB
File Count
72
NPM Version
10.2.3
Node Version
20.10.0
Published on
Dec 29, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
4
Caterpillar is the ultimate logging system for Deno, Node.js, and Web Browsers. Log levels are implemented to the RFC standard. Log entries can be filtered and piped to various streams, including coloured output to the terminal, the browser's console, and debug files. You can even write your own transforms.
The RFC Log Levels are provided by the rfc-log-levels
package which follows RFC 3164 - The BSD Syslog Protocol.
Log Entries that are within the lineLevel range, will have their line information fetched using the get-current-line
package.
The Logger
is what you write your log messages to, which you then pipe to destinations and transforms.
The Filter
transport is used to filter out log levels that we do not want to pass onto the next destination.
The Human
transport is used to convert the Log Entries into a human readable and colourful output.
The Browser
transport is used to send the human output, including colours, to the Web Browser console.
The Transform
is used to write your own transforms, and is what all the others are based from.
To get started for Node.js, setup a new Node.js project for this guide and install Caterpillar.
1mkdir caterpillar-guide 2cd caterpillar-guide 3npm init 4npm install --save caterpillar 5touch index.js
Then edit our index.js
file with the following, that will output all the log messages in JSON format to stdout, and can be run via node index.js
:
1const { Logger } = require('caterpillar') 2const logger = new Logger() 3 4logger.pipe(process.stdout) 5 6logger.log('warn', 'this is a warning, which is level', 4) 7logger.warn('this is a warning, which is level', 4) 8logger.log('debug', 'this is a debug message, which is level', 7) 9logger.warn('this is a debug message, which is level', 7)
Outputting in JSON format is not a nice experience, instead we can do better by using the Human
transport such that it is human readable.
1const { Logger, Human } = require('caterpillar') 2const logger = new Logger() 3 4logger.pipe(new Human()).pipe(process.stdout) 5 6logger.log('warn', 'this is a warning, which is level', 4) 7logger.warn('this is a warning, which is level', 4) 8logger.log('debug', 'this is a debug message, which is level', 7) 9logger.warn('this is a debug message, which is level', 7)
However, perhaps we want to still store the JSON format for querying later. We can pipe the human format to stdout as before, but we can pipe the raw output to a debug file.
1const { Logger, Human } = require('caterpillar') 2const logger = new Logger() 3 4const { createWriteStream } = require('fs') 5logger.pipe(createWriteStream('./debug.log')) 6 7logger.pipe(new Human()).pipe(process.stdout) 8 9logger.log('warn', 'this is a warning, which is level', 4) 10logger.warn('this is a warning, which is level', 4) 11logger.log('debug', 'this is a debug message, which is level', 7) 12logger.warn('this is a debug message, which is level', 7)
Now let's stay for some reason, we want to capitalise all the log messages that are warning levels and higher, we can do this by making our own transport by extending the Transform
.
1const { Logger, Transform, Human } = require('caterpillar') 2const logger = new Logger() 3 4const { createWriteStream } = require('fs') 5logger.pipe(createWriteStream('./debug.log')) 6 7class Uppercase extends Transform { 8 format(entry) { 9 if (entry.levelNumber <= 4) { 10 entry.args.forEach(function (value, index) { 11 if (typeof value === 'string') { 12 entry.args[index] = value.toUpperCase() 13 } 14 }) 15 } 16 return entry 17 } 18} 19 20logger.pipe(new Uppercase()).pipe(new Human()).pipe(process.stdout) 21 22logger.log('warn', 'this is a warning, which is level', 4) 23logger.warn('this is a warning, which is level', 4) 24logger.log('debug', 'this is a debug message, which is level', 7) 25logger.warn('this is a debug message, which is level', 7)
Futhermore, the user probably doesn't need to see debug messages, even though they are useful for debugging. We can filter out the debug messages for the user, but maintain them for the debug.log
file by applying the Filter
transport to the pipe that goes to stdout.
1const { Logger, Transform, Filter, Human } = require('caterpillar') 2const logger = new Logger() 3 4const { createWriteStream } = require('fs') 5logger.pipe(createWriteStream('./debug.log')) 6 7class Uppercase extends Transform { 8 format(entry) { 9 if (entry.levelNumber <= 4) { 10 entry.args.forEach(function (value, index) { 11 if (typeof value === 'string') { 12 entry.args[index] = value.toUpperCase() 13 } 14 }) 15 } 16 return entry 17 } 18} 19 20logger 21 .pipe(new Filter({ filterLevel: 5 })) 22 .pipe(new Uppercase()) 23 .pipe(new Human()) 24 .pipe(process.stdout) 25 26logger.log('warn', 'this is a warning, which is level', 4) 27logger.warn('this is a warning, which is level', 4) 28logger.log('debug', 'this is a debug message, which is level', 7) 29logger.warn('this is a debug message, which is level', 7)
As fetching line information is computationally expensive process, for large applications for performance we probably only want to fetch the line information for messages that we actually show to the user. As such, we should make the filterLevel
and the lineLevel
the same.
1const { Logger, Transform, Filter, Human } = require('caterpillar') 2const level = 5 3const logger = new Logger({ lineLevel: level }) 4 5const { createWriteStream } = require('fs') 6logger.pipe(createWriteStream('./debug.log')) 7 8class Uppercase extends Transform { 9 format(entry) { 10 if (entry.levelNumber <= 4) { 11 entry.args.forEach(function (value, index) { 12 if (typeof value === 'string') { 13 entry.args[index] = value.toUpperCase() 14 } 15 }) 16 } 17 return entry 18 } 19} 20 21logger 22 .pipe(new Filter({ filterLevel: 5 })) 23 .pipe(new Uppercase()) 24 .pipe(new Human()) 25 .pipe(process.stdout) 26 27logger.log('warn', 'this is a warning, which is level', 4) 28logger.warn('this is a warning, which is level', 4) 29logger.log('debug', 'this is a debug message, which is level', 7) 30logger.warn('this is a debug message, which is level', 7)
Finally, if we are using Caterpillar in web browser environments, instead of Node.js, instead of doing:
1const { Logger, Transform, Filter, Human } = require('caterpillar') 2// ... 3logger.pipe(new Human()).pipe(process.stdout) 4// ...
We would pipe to the Browser transform instead of to stdout.
1const { Logger, Transform, Filter, Human, Browser } = require('caterpillar') 2// ... 3logger.pipe(new Human()).pipe(new Browser()) 4// ...
With this, you now have enough information to leverage the cross-platform power of Caterpillar for most purposes, and the power to write your own custom transforms which can be published as their own packages and shared.
npm install --save caterpillar
import * as pkg from ('caterpillar')
const pkg = require('caterpillar')
1import * as pkg from 'https://unpkg.com/caterpillar@^8.2.0/edition-deno/index.ts'
1<script type="module"> 2 import * as pkg from '//cdn.skypack.dev/caterpillar@^8.2.0' 3</script>
1<script type="module"> 2 import * as pkg from '//unpkg.com/caterpillar@^8.2.0' 3</script>
1<script type="module"> 2 import * as pkg from '//dev.jspm.io/caterpillar@8.2.0' 3</script>
This package is published with the following editions:
caterpillar
aliases caterpillar/index.cjs
which uses the Editions Autoloader to automatically select the correct edition for the consumer's environmentcaterpillar/source/index.ts
is TypeScript source code with Import for modulescaterpillar/edition-browsers/index.js
is TypeScript compiled against ES2022 for web browsers with Import for modulescaterpillar/edition-es2022/index.js
is TypeScript compiled against ES2022 for Node.js 14 || 16 || 18 || 20 || 21 with Require for modulescaterpillar/edition-es2017/index.js
is TypeScript compiled against ES2017 for Node.js 8 || 10 || 12 || 14 || 16 || 18 || 20 || 21 with Require for modulescaterpillar/edition-es2015/index.js
is TypeScript compiled against ES2015 for Node.js 6 || 8 || 10 || 12 || 14 || 16 || 18 || 20 || 21 with Require for modulescaterpillar/edition-es5/index.js
is TypeScript compiled against ES5 for Node.js 4 || 6 || 8 || 10 || 12 || 14 || 16 with Require for modulescaterpillar/edition-es2017-esm/index.js
is TypeScript compiled against ES2017 for Node.js 12 || 14 || 16 || 18 || 20 || 21 with Import for modulescaterpillar/edition-types/index.d.ts
is TypeScript compiled Types with Import for modulescaterpillar/edition-deno/index.ts
is TypeScript source code made to be compatible with DenoDiscover the release history by heading on over to the HISTORY.md
file.
Discover how to contribute via the CONTRIBUTING.md
file.
Unless stated otherwise all works are:
and licensed under:
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
security policy file detected
Details
Reason
license file detected
Details
Reason
5 existing vulnerabilities detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 1
Details
Reason
Found 0/12 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 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
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
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