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

batching-logger

v0.1.1

Published

Stores logs in batches to optimize performance and reduce system load.

Readme

batching-logger

npm version npm downloads

성능을 최적화하고 시스템 부하를 줄이기 위해 로그를 일괄적으로 저장합니다.

설치

$ npm install batching-logger

사용법

const { BatchingLogger, LoggerEvent } = require('batching-logger');

const logger = new BatchingLogger({
  saveInterval: 5000,         // 로그 저장 주기 (기본값: 5000ms)
  minLogBufferLength: 1,      // 저장을 위한 최소 로그 개수 (기본값: 1)
  maxLogBufferLength: 500     // 최대 버퍼 크기 (기본값: 500)
});

logger.on(LoggerEvent.SendSave, (logs) => {
  console.log('Logs saved:', logs);
});

logger.resolve('Log entry 1');
logger.resolve({ message: 'Log entry 2' });

기능

new BatchingLogger(options)

| 옵션 | 설명 | 기본값 | |--------------------|-------------------------------------------|------------| | saveInterval | 로그 저장 주기 (ms) | 5000 | | minLogBufferLength | 자동 저장을 위한 최소 로그 수 | 1 | | maxLogBufferLength | 최대 버퍼 크기, 초과 시 자동 저장됨 | 500 |

logger.resolve(log)

  • 로그를 버퍼에 추가합니다.
  • Promise도 지원되며, 자동으로 resolve됩니다.
  • maxLogBufferLength에 도달하면 자동 저장됩니다.
logger.resolve('text log');
logger.resolve({ type: 'info', message: 'structured log' });

logger.clearLogs()

  • 로그 버퍼를 초기화합니다.
logger.clearLogs();

logger.getLogs()

  • 현재 로그 버퍼 상태를 배열로 반환합니다.
const logs = logger.getLogs();

logger.startLogging()

  • 주기적인 자동 저장(SendSave)을 시작합니다.
  • 생성자 호출 시 자동으로 실행됩니다.
logger.startLogging();

logger.stopLogging()

  • 자동 저장 타이머를 중지합니다.
logger.stopLogging();

logger.forceSave()

  • 버퍼에 남은 로그를 강제로 저장 이벤트로 전송합니다.
logger.forceSave();

LoggerEvent.SendSave

  • 저장 이벤트가 발생할 때 실행됩니다.
  • 로그 배열이 인자로 전달됩니다.
logger.on(LoggerEvent.SendSave, (logs) => {
  console.log('Logs saved:', logs);
});