npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sylphx/cat-file

v0.1.0

Published

File and stream transports for @sylphx/cat logger

Downloads

5

Readme

@sylphx/cat-file

File and stream transports for @sylphx/cat logger

npm version License: MIT

1.14 KBFile loggingStream supportUniversal runtime

Installation

npm install @sylphx/cat @sylphx/cat-file

Description

Provides file-based and stream-based transports for @sylphx/cat. Write logs to files with automatic buffering, or pipe to custom streams. Works in both Bun and Node.js environments.

Usage Examples

File Transport

import { createLogger } from '@sylphx/cat'
import { fileTransport } from '@sylphx/cat-file'

const logger = createLogger({
  transports: [
    fileTransport({ path: './logs/app.log' })
  ]
})

logger.info('This goes to the file')
// Writes to ./logs/app.log

Multiple File Transports (Log Rotation)

import { createLogger } from '@sylphx/cat'
import { fileTransport } from '@sylphx/cat-file'

const logger = createLogger({
  transports: [
    fileTransport({ path: './logs/app.log' }),
    fileTransport({ path: './logs/error.log' })
  ]
})

// You can filter by level in your application logic
logger.info('General log')  // Goes to both files
logger.error('Error log')   // Goes to both files

Stream Transport

import { createLogger } from '@sylphx/cat'
import { streamTransport } from '@sylphx/cat-file'
import { createWriteStream } from 'node:fs'

const stream = createWriteStream('./logs/app.log', { flags: 'a' })

const logger = createLogger({
  transports: [
    streamTransport({ stream })
  ]
})

logger.info('This goes to the stream')

API Reference

fileTransport(options: FileTransportOptions): Transport

Creates a file transport that writes logs to a file.

Options:

  • path: string - File path (required)
  • mode?: number - File mode (default: 0o666)
  • flags?: string - File open flags (default: 'a' for append)

Features:

  • Automatic directory creation
  • Buffered writes for performance
  • Async flush support
  • Works in Bun and Node.js

Example:

fileTransport({
  path: './logs/app.log',
  mode: 0o644,
  flags: 'a'
})

streamTransport(options: StreamTransportOptions): Transport

Creates a stream transport that writes logs to a writable stream.

Options:

  • stream: WritableStream - Writable stream (required)

Features:

  • Works with any Node.js writable stream
  • Buffered writes
  • Async flush support

Example:

import { createWriteStream } from 'node:fs'

streamTransport({
  stream: createWriteStream('./logs/app.log')
})

Transport Methods

Both transports implement the standard Transport interface:

  • log(entry: LogEntry, formatted: string): void - Write a log entry
  • flush(): Promise<void> - Flush pending writes
  • close(): Promise<void> - Close the transport

Advanced Usage

Graceful Shutdown

const logger = createLogger({
  transports: [fileTransport({ path: './logs/app.log' })]
})

process.on('SIGTERM', async () => {
  await logger.close()  // Flushes and closes all transports
  process.exit(0)
})

Multiple Outputs

import { createLogger, consoleTransport } from '@sylphx/cat'
import { fileTransport } from '@sylphx/cat-file'

const logger = createLogger({
  transports: [
    consoleTransport(),  // Console output
    fileTransport({ path: './logs/app.log' })  // File output
  ]
})

logger.info('Logged to both console and file')

Package Size

  • Minified: ~3.5 KB
  • Minified + Gzipped: 1.14 KB
  • No additional dependencies

Runtime Compatibility

  • ✅ Bun 1.0+
  • ✅ Node.js 18+
  • ⚠️ Browser/Edge (use stream transport with custom writable streams)

Links

Related Packages

License

MIT © Kyle Zhu