hydrakit/log 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hydrakit/log

Composer 安装命令:

composer require hydrakit/log

包简介

Logging library for Hydra PHP framework

README 文档

README

A minimal PSR-3 logger that writes one plain-text line per record to a writable stream. No handlers, no processors, no formatters config — Hydra's logging is a single deliberate class, the data-layer-style "ship the verb" of logging.

How it works

StreamLogger is constructed with an already-open, writable stream — a file handle, php://stderr, php://memory in tests. Sink selection is the caller's concern: the class only formats and writes. The app's service provider is what opens LOG_PATH (falling back to stderr when the path is unwritable) and hands the stream in.

use Hydra\Log\StreamLogger;

$logger = new StreamLogger(fopen('php://stderr', 'w'));
$logger->info('request handled', ['method' => 'GET', 'status' => 200]);
// [2026-06-20T01:44:06+00:00] INFO: request handled {"method":"GET","status":200}

Each record renders as [ISO-8601] LEVEL: message <context>:

  • Placeholders{key} tokens are interpolated from context per PSR-3. Substitution is keyed on value type, not truthiness, so 0, '' and false render rather than vanish. A placeholder with no usable value is left intact.
  • Leftover context is appended as JSON. A Throwable under the conventional exception key is rendered as a readable class/message/file/line + trace instead.

Failures never escalate

A broken sink (closed stream, full disk) must not take the application down with it: the write is @fwrite and guarded by is_resource. Logging is best-effort by design.

What it deliberately is not

No log rotation, no level filtering, no multiple sinks. Those are the app's job if it ever needs them — bind a different Psr\Log\LoggerInterface implementation (Monolog, a fan-out logger) in the service provider and every consumer follows, because consumers depend on the PSR-3 interface, never on this class.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-07-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固