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

@ya-hari/yureilog.js

v0.2.0

Published

A small smart logger with rotation and remote batching

Readme

YureiLog.js

軽量で設定しやすい Node.js 向けロガー。タイムスタンプ・ラベル・色分けを自動で付与し、ファイルローテーション、リモートバッチ送信、JSON 出力などの便利な機能を備えます。

目次

  • Quick Start
  • インストール
  • CommonJS / ESM の使用例
  • API 参照(主要オプション)
  • Time zone の注意点
  • Publish 前チェックリスト
  • PowerShell での実行例

Quick Start

インストール(プロジェクトに追加):

npm install @ya-hari/yureilog.js

CommonJS での使い方:

const SmartLogger = require('@ya-hari/yureilog.js');
const logger = new SmartLogger({ level: 'info', label: 'MyApp' });
logger.info('hello world');

ESM(import)での使い方:

import SmartLogger from '@ya-hari/yureilog.js';
const logger = new SmartLogger({ label: 'ESM' });
logger.info('hello esm');

API 参照(主要オプション)

  • level: 'error'|'warn'|'info'|'debug' — ログ出力レベル(デフォルト: 'info')
  • env: 'production'|'development' — production では debug を抑制
  • label: string — ログ行に付与されるラベル
  • colors: boolean — ANSI カラーのオン/オフ(デフォルト: true)
  • json: boolean — JSON 出力モード(監査や ELK 送信用)
  • file: string — ログファイルのパス(省略するとコンソール出力のみ)
  • rotation: { size: number, maxFiles?: number } — サイズベースのローテーション(file 必須)
  • remote: { url: string, intervalMs?: number, batchSize?: number, headers?: Record<string,string>, timeoutMs?: number, maxBuffer?: number }
  • timeZone?: string — タイムスタンプの出力タイムゾーン(例: 'Asia/Tokyo')。未指定時は UTC ISO 文字列を使用。
  • remoteReliable?: boolean — リモート送信失敗時のディスク永続化を有効化
  • remoteQueuePath?: string — 永続化キューのパス
  • remoteGzip?: boolean — 送信時に gzip 圧縮を行う

主要メソッド:

  • info(msg, ...ctx)
  • warn(msg, ...ctx)
  • error(msg|Error, ...ctx)
  • debug(msg, ...ctx)
  • log(level, msg, ...ctx)
  • child(overrides) — 子ロガーを生成
  • setLevel(level)
  • flushRemote(): Promise — バッファの即時送信
  • close() — ストリームやタイマーを閉じる

Time zone の注意点

timeZone オプションは IANA タイムゾーン文字列(例: 'Asia/Tokyo')を受け付けます。Node.js のビルドに依存して ICU サポートが必要なため、環境によっては未対応または挙動が異なることがあります。サポートされない場合は自動的に UTC の ISO 文字列にフォールバックします。

Publish 前チェックリスト

ローカルで以下を実行して最終確認してください(PowerShell 例):

npm ci
npm run build
npm test

pack を確認する:

npm pack --dry-run

パブリッシュ:

npm publish --access public

(注)公開前に package.jsonnameversionrepositorykeywordsfiles をチェックしてください。

PowerShell 実行例(デバッグ)

ビルドとテストを一度に実行する:

npm run build; npm test

ESM デモ(ローカル):

node test/demo-esm-run.mjs

FAQ

Q: bun で動きますか?

A: bun は高速なランタイムですが、環境差があるため動作検証が必要です。commonjs モジュールとして動く可能性は高いですが、fsIntl の挙動は環境毎に異なります。bun でのテストを推奨します。

Q: 永続化キューは安全ですか?

A: 現状は簡易的な JSONL ファイルへの追記/読み取りで永続化しています。高負荷時や複数プロセスでの同時アクセスには追加のロックやトランザクション制御が必要です。


この README はリリース前にさらに整備できます(例: API の詳細な型定義、追加の使用例、ベストプラクティス)。次に追加してほしいセクションがあれば教えてください。

ローカルからの安全な公開手順(GitHub Actions を使わない)

ローカル環境だけで公開したい場合は、npm のトークンを環境変数 NPM_TOKEN に設定する方法が便利で安全です。手順:

PowerShell の場合(推奨):

$env:NPM_TOKEN = '<your-npm-token-here>'
npm run release:ps

Node スクリプト経由(クロスプラットフォーム):

setx NPM_TOKEN "<your-npm-token-here>"; npm run release:local

インタラクティブにログインしたい場合は:

npm run preflight; npm login; npm publish --access public

注: スクリプトは一時的に ~/.npmrc にトークンを埋め込み、公開後に自動で削除します。公開前に package.jsonnameversion を再確認してください。