Skip to content

refactor(act): extract logger into port/adapter pattern#517

Merged
Rotorsoft merged 2 commits intomasterfrom
refactor/logger-port
Mar 25, 2026
Merged

refactor(act): extract logger into port/adapter pattern#517
Rotorsoft merged 2 commits intomasterfrom
refactor/logger-port

Conversation

@Rotorsoft
Copy link
Copy Markdown
Owner

Summary

  • Replace hard-coded pino dependency with a Logger port following the same port() factory pattern as store() and cache()
  • Default ConsoleLogger emits JSON lines in production, colorized output in development — zero external dependencies
  • New @rotorsoft/act-pino adapter package for pino users
  • Remove pino and pino-pretty from @rotorsoft/act dependencies

Changes

Core (@rotorsoft/act)

  • Logger interface in types/ports.ts (extends Disposable)
  • ConsoleLogger adapter with pino-inspired optimizations (numeric level gating, noop method replacement, stdout.write)
  • log() port via port() factory — const logger = log() in consuming files
  • ports.ts fully documented with JSDoc, organized into sections

New package (@rotorsoft/act-pino)

  • PinoLogger adapter wrapping pino, with dispose() flush support
  • Full test coverage

Updated

  • act-pg/PostgresStore.ts — uses log() port
  • event-sourcing.spec.ts — replaced logger spy tests with behavior assertions
  • README, docusaurus docs (intro, configuration, event-sourcing)
  • vite.config.ts — added act-pino alias

Test plan

  • 714 tests passing (46 test files)
  • 100% coverage on ConsoleLogger and PinoLogger
  • 100% coverage on all other changed source files
  • Build passes across all packages
  • Lint passes (pre-commit hook)

🤖 Generated with Claude Code

rotorsoft and others added 2 commits March 25, 2026 11:10
Replace the hard-coded pino dependency with a Logger port following the
same pattern as store() and cache(). The default ConsoleLogger emits
JSON lines in production and colorized output in development with zero
external dependencies. Pino moves to a new @rotorsoft/act-pino adapter.

- Add Logger interface (extends Disposable) to types/ports.ts
- Add ConsoleLogger adapter with pino-inspired optimizations
- Add log() port via port() factory, consistent with store() and cache()
- Create @rotorsoft/act-pino package with PinoLogger adapter
- Remove pino and pino-pretty from @rotorsoft/act dependencies
- Update act-pg to use log() port
- Add full test coverage for ConsoleLogger and PinoLogger
- Update README, docusaurus docs, and vitest config

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add @rotorsoft/act-pino to libraries section with full badge set
- Add missing Coverage badge to act-diagram
- Add blank lines between library entries for readability
- Reorder: act, act-pg, act-pino, act-patch, act-sse, act-diagram

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Rotorsoft Rotorsoft merged commit db671d6 into master Mar 25, 2026
5 checks passed
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version @rotorsoft/act-v0.25.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version @rotorsoft/act-pg-v0.14.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant