Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

caterpillar

Package Overview
Dependencies
Maintainers
2
Versions
150
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

caterpillar - npm Package Compare versions

Comparing version 6.0.0-next.1595384191.84cf2aa1d33d5588cf1ec98df41f88124b584c0f to 6.0.0-next.1595392757.94479b0eb1308e20c08350304b5061e17ec1bd1c

deno.ts

3

compiled-types/human.d.ts

@@ -22,4 +22,3 @@ import { LogEntry } from './logger.js'

* ``` javascript
* import Logger from 'caterpillar'
* import Human from 'caterpillar-human'
* import { Logger, Human } from 'caterpillar'
* const logger = new Logger()

@@ -26,0 +25,0 @@ * const human = new Human()

@@ -37,4 +37,2 @@ import { LevelInfo, LevelsMap } from 'rfc-log-levels'

* const logger = new Logger()
* // Via create helper
* const logger = Logger.create()
* ```

@@ -87,4 +85,12 @@ */

log(...args: any): void
/** Alias for log which prefixes the error log level */
error(...args: any): void
/** Alias for log which prefixes the warn log level */
warn(...args: any): void
/** Alias for log which prefixes the info log level */
info(...args: any): void
/** Alias for log which prefixes the debug log level */
debug(...args: any): void
}
export default Logger
//# sourceMappingURL=logger.d.ts.map
/** Something that we can write to. */
interface Writable {
declare type Writable = {
write(chunk: any): any
end?(cb?: () => void): void
close?(): Promise<void>
close?(): Promise<void> | void
}

@@ -49,4 +49,6 @@ export interface TransformConfig {

pipe<T extends Writable>(to: T): T
/** Maintain a write queue such that multiple Deno writes do not stall */
private writer
/** Write to the child pipes. */
write(chunk: any): void
write(chunk: any): Promise<void>
/** Close the child pipes. */

@@ -53,0 +55,0 @@ close(): Promise<void>

@@ -16,4 +16,3 @@ import { Transform } from './transform.js'

* ``` javascript
* import Logger from 'caterpillar'
* import Human from 'caterpillar-human'
* import { Logger, Human } from 'caterpillar'
* const logger = new Logger()

@@ -20,0 +19,0 @@ * const human = new Human()

@@ -12,4 +12,2 @@ import getLogLevel, { rfcLogLevels } from 'rfc-log-levels'

* const logger = new Logger()
* // Via create helper
* const logger = Logger.create()
* ```

@@ -110,3 +108,19 @@ */

}
/** Alias for log which prefixes the error log level */
error(...args) {
this.write(['error', ...args])
}
/** Alias for log which prefixes the warn log level */
warn(...args) {
this.write(['warn', ...args])
}
/** Alias for log which prefixes the info log level */
info(...args) {
this.write(['info', ...args])
}
/** Alias for log which prefixes the debug log level */
debug(...args) {
this.write(['debug', ...args])
}
}
export default Logger

@@ -28,2 +28,4 @@ /**

var _a
/** Maintain a write queue such that multiple Deno writes do not stall */
this.writer = Promise.resolve()
this.config = {

@@ -51,15 +53,26 @@ pipes:

write(chunk) {
// format now, so that we have the correct stack
const data = this.format(chunk)
// exclude filtered entries
if (data === null) return
// pipe to child transforms and streams
for (const pipe of this.config.pipes) {
if (pipe instanceof Transform || typeof data === 'string') {
// compatibility with caterpillar transforms
pipe.write(data)
} else {
// compatibility with node streams
pipe.write(JSON.stringify(data))
if (data == null) return this.writer
// now delegate back to the pipe
this.writer = this.writer.then(async () => {
// pipe to child transforms and streams
for (const pipe of this.config.pipes) {
if (pipe instanceof Transform) {
// compatibility with caterpillar transforms
await pipe.write(data)
} else {
const str = typeof data === 'string' ? data : JSON.stringify(data)
if (typeof TextEncoder !== 'undefined') {
// compatibility with deno and later node streams
await pipe.write(new TextEncoder().encode(str))
} else {
// compatibility with earlier node streams
await pipe.write(str)
}
}
}
}
})
return this.writer
}

@@ -84,4 +97,5 @@ /** Close the child pipes. */

end(cb) {
this.close().finally(cb)
const p = this.close()
if (cb) p.finally(cb)
}
}

@@ -30,4 +30,3 @@ // Imports

* ``` javascript
* import Logger from 'caterpillar'
* import Human from 'caterpillar-human'
* import { Logger, Human } from 'caterpillar'
* const logger = new Logger()

@@ -34,0 +33,0 @@ * const human = new Human()

@@ -51,4 +51,2 @@ import { __ as __fdPolyfill } from 'https://deno.land/x/dirname/mod.ts'

* const logger = new Logger()
* // Via create helper
* const logger = Logger.create()
* ```

@@ -146,4 +144,24 @@ */

}
/** Alias for log which prefixes the error log level */
error(...args: any) {
this.write(['error', ...args])
}
/** Alias for log which prefixes the warn log level */
warn(...args: any) {
this.write(['warn', ...args])
}
/** Alias for log which prefixes the info log level */
info(...args: any) {
this.write(['info', ...args])
}
/** Alias for log which prefixes the debug log level */
debug(...args: any) {
this.write(['debug', ...args])
}
}
export default Logger
/** Something that we can write to. */
interface Writable {
type Writable = {
write(chunk: any): any
end?(cb?: () => void): void
close?(): Promise<void>
close?(): Promise<void> | void
}

@@ -65,17 +65,31 @@

/** Maintain a write queue such that multiple Deno writes do not stall */
private writer = Promise.resolve()
/** Write to the child pipes. */
write(chunk: any) {
// format now, so that we have the correct stack
const data = this.format(chunk)
// exclude filtered entries
if (data === null) return
// pipe to child transforms and streams
for (const pipe of this.config.pipes) {
if (pipe instanceof Transform || typeof data === 'string') {
// compatibility with caterpillar transforms
pipe.write(data)
} else {
// compatibility with node streams
pipe.write(JSON.stringify(data))
if (data == null) return this.writer
// now delegate back to the pipe
this.writer = this.writer.then(async () => {
// pipe to child transforms and streams
for (const pipe of this.config.pipes) {
if (pipe instanceof Transform) {
// compatibility with caterpillar transforms
await pipe.write(data)
} else {
const str = typeof data === 'string' ? data : JSON.stringify(data)
if (typeof TextEncoder !== 'undefined') {
// compatibility with deno and later node streams
await pipe.write(new TextEncoder().encode(str))
} else {
// compatibility with earlier node streams
await pipe.write(str)
}
}
}
}
})
return this.writer
}

@@ -102,4 +116,5 @@

end(cb?: () => void) {
this.close().finally(cb)
const p = this.close()
if (cb) p.finally(cb)
}
}

@@ -57,4 +57,3 @@ 'use strict'

* ``` javascript
* import Logger from 'caterpillar'
* import Human from 'caterpillar-human'
* import { Logger, Human } from 'caterpillar'
* const logger = new Logger()

@@ -61,0 +60,0 @@ * const human = new Human()

@@ -57,4 +57,2 @@ 'use strict'

* const logger = new Logger()
* // Via create helper
* const logger = Logger.create()
* ```

@@ -146,4 +144,20 @@ */

}
/** Alias for log which prefixes the error log level */
error(...args) {
this.write(['error', ...args])
}
/** Alias for log which prefixes the warn log level */
warn(...args) {
this.write(['warn', ...args])
}
/** Alias for log which prefixes the info log level */
info(...args) {
this.write(['info', ...args])
}
/** Alias for log which prefixes the debug log level */
debug(...args) {
this.write(['debug', ...args])
}
}
exports.Logger = Logger
exports.default = Logger

@@ -30,2 +30,4 @@ 'use strict'

constructor(opts) {
/** Maintain a write queue such that multiple Deno writes do not stall */
this.writer = Promise.resolve()
this.config = {

@@ -49,15 +51,26 @@ pipes: opts?.pipes ?? [],

write(chunk) {
// format now, so that we have the correct stack
const data = this.format(chunk)
// exclude filtered entries
if (data === null) return
// pipe to child transforms and streams
for (const pipe of this.config.pipes) {
if (pipe instanceof Transform || typeof data === 'string') {
// compatibility with caterpillar transforms
pipe.write(data)
} else {
// compatibility with node streams
pipe.write(JSON.stringify(data))
if (data == null) return this.writer
// now delegate back to the pipe
this.writer = this.writer.then(async () => {
// pipe to child transforms and streams
for (const pipe of this.config.pipes) {
if (pipe instanceof Transform) {
// compatibility with caterpillar transforms
await pipe.write(data)
} else {
const str = typeof data === 'string' ? data : JSON.stringify(data)
if (typeof TextEncoder !== 'undefined') {
// compatibility with deno and later node streams
await pipe.write(new TextEncoder().encode(str))
} else {
// compatibility with earlier node streams
await pipe.write(str)
}
}
}
}
})
return this.writer
}

@@ -82,5 +95,6 @@ /** Close the child pipes. */

end(cb) {
this.close().finally(cb)
const p = this.close()
if (cb) p.finally(cb)
}
}
exports.Transform = Transform

@@ -16,4 +16,3 @@ import { Transform } from './transform.js'

* ``` javascript
* import Logger from 'caterpillar'
* import Human from 'caterpillar-human'
* import { Logger, Human } from 'caterpillar'
* const logger = new Logger()

@@ -20,0 +19,0 @@ * const human = new Human()

@@ -12,4 +12,2 @@ import getLogLevel, { rfcLogLevels } from 'rfc-log-levels'

* const logger = new Logger()
* // Via create helper
* const logger = Logger.create()
* ```

@@ -101,3 +99,19 @@ */

}
/** Alias for log which prefixes the error log level */
error(...args) {
this.write(['error', ...args])
}
/** Alias for log which prefixes the warn log level */
warn(...args) {
this.write(['warn', ...args])
}
/** Alias for log which prefixes the info log level */
info(...args) {
this.write(['info', ...args])
}
/** Alias for log which prefixes the debug log level */
debug(...args) {
this.write(['debug', ...args])
}
}
export default Logger

@@ -27,2 +27,4 @@ /**

constructor(opts) {
/** Maintain a write queue such that multiple Deno writes do not stall */
this.writer = Promise.resolve()
this.config = {

@@ -46,15 +48,26 @@ pipes: opts?.pipes ?? [],

write(chunk) {
// format now, so that we have the correct stack
const data = this.format(chunk)
// exclude filtered entries
if (data === null) return
// pipe to child transforms and streams
for (const pipe of this.config.pipes) {
if (pipe instanceof Transform || typeof data === 'string') {
// compatibility with caterpillar transforms
pipe.write(data)
} else {
// compatibility with node streams
pipe.write(JSON.stringify(data))
if (data == null) return this.writer
// now delegate back to the pipe
this.writer = this.writer.then(async () => {
// pipe to child transforms and streams
for (const pipe of this.config.pipes) {
if (pipe instanceof Transform) {
// compatibility with caterpillar transforms
await pipe.write(data)
} else {
const str = typeof data === 'string' ? data : JSON.stringify(data)
if (typeof TextEncoder !== 'undefined') {
// compatibility with deno and later node streams
await pipe.write(new TextEncoder().encode(str))
} else {
// compatibility with earlier node streams
await pipe.write(str)
}
}
}
}
})
return this.writer
}

@@ -79,4 +92,5 @@ /** Close the child pipes. */

end(cb) {
this.close().finally(cb)
const p = this.close()
if (cb) p.finally(cb)
}
}

@@ -16,4 +16,8 @@ # History

- This is a dramatic performance improvement for large applications, as fetching line levels for every log entry, even ones filtered out, was not performant
- Closes [issue #16](https://github.com/bevry/caterpillar/issues/16)
- Caterpillar Transforms are no longer Node.js Streams, as using them was a major performance overhead
- We can still pipe to Caterpillar Transforms as well as to Node.js streams and WHATWG/Deno streams
- Closes [issue #17](https://github.com/bevry/caterpillar/issues/17)
- Add `error`, `warn`, `info`, `debug` aliases to the logger
- Thanks to [Kirill Chernyshov](https://github.com/DeLaGuardo) for [issue #12](https://github.com/bevry/caterpillar/issues/12)
- Updated dependencies, [base files](https://github.com/bevry/base), and [editions](https://editions.bevry.me) using [boundation](https://github.com/bevry/boundation)

@@ -20,0 +24,0 @@

{
"title": "Caterpillar",
"name": "caterpillar",
"version": "6.0.0-next.1595384191.84cf2aa1d33d5588cf1ec98df41f88124b584c0f",
"version": "6.0.0-next.1595392757.94479b0eb1308e20c08350304b5061e17ec1bd1c",
"description": "Caterpillar is the ultimate logging system for Node.js. Log entries can automatically include their caller's line, method, and file information. You can pipe the output off to different locations and to your own customisations. Log levels are implemented to the RFC standard, and it works with web browsers, with coloured console output.",

@@ -6,0 +6,0 @@ "homepage": "https://github.com/bevry/caterpillar",

@@ -30,4 +30,3 @@ // Imports

* ``` javascript
* import Logger from 'caterpillar'
* import Human from 'caterpillar-human'
* import { Logger, Human } from 'caterpillar'
* const logger = new Logger()

@@ -34,0 +33,0 @@ * const human = new Human()

@@ -42,4 +42,2 @@ import getLogLevel, { rfcLogLevels, LevelInfo, LevelsMap } from 'rfc-log-levels'

* const logger = new Logger()
* // Via create helper
* const logger = Logger.create()
* ```

@@ -137,4 +135,24 @@ */

}
/** Alias for log which prefixes the error log level */
error(...args: any) {
this.write(['error', ...args])
}
/** Alias for log which prefixes the warn log level */
warn(...args: any) {
this.write(['warn', ...args])
}
/** Alias for log which prefixes the info log level */
info(...args: any) {
this.write(['info', ...args])
}
/** Alias for log which prefixes the debug log level */
debug(...args: any) {
this.write(['debug', ...args])
}
}
export default Logger
/** Something that we can write to. */
interface Writable {
type Writable = {
write(chunk: any): any
end?(cb?: () => void): void
close?(): Promise<void>
close?(): Promise<void> | void
}

@@ -65,17 +65,31 @@

/** Maintain a write queue such that multiple Deno writes do not stall */
private writer = Promise.resolve()
/** Write to the child pipes. */
write(chunk: any) {
// format now, so that we have the correct stack
const data = this.format(chunk)
// exclude filtered entries
if (data === null) return
// pipe to child transforms and streams
for (const pipe of this.config.pipes) {
if (pipe instanceof Transform || typeof data === 'string') {
// compatibility with caterpillar transforms
pipe.write(data)
} else {
// compatibility with node streams
pipe.write(JSON.stringify(data))
if (data == null) return this.writer
// now delegate back to the pipe
this.writer = this.writer.then(async () => {
// pipe to child transforms and streams
for (const pipe of this.config.pipes) {
if (pipe instanceof Transform) {
// compatibility with caterpillar transforms
await pipe.write(data)
} else {
const str = typeof data === 'string' ? data : JSON.stringify(data)
if (typeof TextEncoder !== 'undefined') {
// compatibility with deno and later node streams
await pipe.write(new TextEncoder().encode(str))
} else {
// compatibility with earlier node streams
await pipe.write(str)
}
}
}
}
})
return this.writer
}

@@ -102,4 +116,5 @@

end(cb?: () => void) {
this.close().finally(cb)
const p = this.close()
if (cb) p.finally(cb)
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc