aagjalpankaj/logstan 问题修复 & 功能扩展

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

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

aagjalpankaj/logstan

最新稳定版本:v0.2.0

Composer 安装命令:

composer require --dev aagjalpankaj/logstan

包简介

PHPStan extension for Laravel applications to enforce consistent logging practices.

README 文档

README

ci Downloads

About

LogStan is a PHPStan extension that helps you to enforce structured and consistent logging in Laravel.

Example Output

./vendor/bin/logstan analyse

 ------ -------------------------------------------------------------------------------------------- 
  Line   Actions/CreateOrderAction.php                                                   
 ------ -------------------------------------------------------------------------------------------- 
  21     Log message "order created" should start with an uppercase letter.                                    
  67     Log context key "orderId" should be in snake_case format.                                    
  94     Log context has too many keys (11). Maximum allowed are 10.                                 
 ------ -------------------------------------------------------------------------------------------- 

 ------ --------------------------------------------------------------------------------------------
  Line   Services/ShopifyService.php                                                                             
 ------ -------------------------------------------------------------------------------------------- 
  57     Log context value of key "order" must be scalar, null or array of scalar. 
         "App\Models\Order" provided.   
 ------ -------------------------------------------------------------------------------------------- 

                                                                                                                        
 [ERROR] Found 4 errors                                                                                                
                                                                                                                     

Installation | Usage | Logging standards enforced

Installation

composer require --dev aagjalpankaj/logstan

Usage

Analyzing Logs

./vendor/bin/logstan analyse

This command will scan your application and report any inconsistencies or potential problems with the logs in your application.

Getting Insights

./vendor/bin/logstan insights

This command provides insights about logs in your application.

Configuration (Optional)

cp ./vendor/aagjalpankaj/logstan/logstan.neon.dist logstan.neon 

You can override default presets in logstan.neon

Help

For more information about available commands and options:

./vendor/bin/logstan --help

Logging standards enforced

Logstan ensures your Laravel application follows best practices for logging by enforcing the following standards:

Log Messages

Standard Description
Non-empty requirement All log messages must contain meaningful content
Character limit Messages are validated against maximum length constraints
Proper capitalization Messages must begin with uppercase letters for consistency

Log Context

Standard Description
Array structure Context data must be provided as a properly formatted array
Key limit Maximum of 10 context keys to maintain readability
Naming convention Keys must use snake_case format and be non-empty strings
Data types Values restricted to scalar types or null (arrays/objects prohibited)
Value length Context values limited to 100 characters maximum
Security compliance Automatic detection and prevention of sensitive information in keys

Contributing

Found a bug or have a feature request? We'd love to hear from you!

License

This package is open-sourced software licensed under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固