bytetcore/lalog 问题修复 & 功能扩展

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

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

bytetcore/lalog

最新稳定版本:1.0.2

Composer 安装命令:

composer require bytetcore/lalog

包简介

A robust Laravel SQL Query Logger that logs all database queries to files with rotation, performance metrics, and cross-database compatibility.

README 文档

README

Latest Version License Latest Stable Version Total Downloads Latest Unstable Version

Automatically log all SQL queries to files with binding interpolation, time tracking, and file rotation support. Perfect for debugging and performance analysis during development.

Features

  • 🔍 Full SQL Logging — Captures every query with bindings interpolated
  • ⏱️ Query Time — Records execution time for each query
  • 📁 File Rotation — Automatically creates new files when size limit is reached
  • 🗑️ Auto Clear — Optionally clears previous logs each request cycle
  • ⚙️ Configurable — Disk, directory, format, max size, extension — all customizable
  • 🚀 Zero Config — Works out of the box with sensible defaults

Requirements

  • PHP 8.0+
  • Laravel 9.x+

Installation

composer require bytetcore/lalog --dev

The package auto-discovers its ServiceProvider. No manual registration needed.

Publish Config (Optional)

php artisan vendor:publish --tag=lalog-config

Configuration

Add to your .env:

APP_LOG_QUERY=true

Available Options

Option Env Variable Default Description
enabled APP_LOG_QUERY false Enable/disable query logging
disk LALOG_DISK local Storage disk (any disk from filesystems.php)
directory LALOG_DIRECTORY query Directory within the disk
max_size LALOG_MAX_SIZE 2000000 Max file size in bytes (~2MB)
format LALOG_FORMAT sql-{date} File name format ({date} placeholder)
date_format LALOG_DATE_FORMAT Y-m-d PHP date format for {date}
extension LALOG_EXTENSION sql File extension
clear_on_start LALOG_CLEAR_ON_START true Delete current day's log on start

Example Config

// config/lalog.php
return [
    'enabled'        => env('APP_LOG_QUERY', false),
    'disk'           => env('LALOG_DISK', 'local'),
    'directory'      => env('LALOG_DIRECTORY', 'query'),
    'max_size'       => env('LALOG_MAX_SIZE', 2000000),
    'format'         => env('LALOG_FORMAT', 'sql-{date}'),
    'date_format'    => env('LALOG_DATE_FORMAT', 'Y-m-d'),
    'extension'      => env('LALOG_EXTENSION', 'sql'),
    'clear_on_start' => env('LALOG_CLEAR_ON_START', true),
];

Output Example

File: storage/app/query/sql-2026-04-03.sql

----------START---------
Date: 2026-04-03 13:45:12
Time query: 2.34(ms)
select * from `users` where `email` = 'john@example.com' limit 1;
----------END----------

Date: 2026-04-03 13:45:12
Time query: 0.89(ms)
select * from `posts` where `user_id` = '1' order by `created_at` desc;
----------END----------

File Rotation

When a log file exceeds max_size, new files are created with an incremented index:

query/sql-2026-04-03.sql      (2MB reached)
query/sql-2026-04-03-1.sql    (next file)
query/sql-2026-04-03-2.sql    (and so on)

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

See AUTHORS for the list of contributors.

License

Licensed under the Apache License 2.0. Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2026-04-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固