aaix/laravel-smart-log 问题修复 & 功能扩展

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

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

aaix/laravel-smart-log

最新稳定版本:v1.0.4

Composer 安装命令:

composer require aaix/laravel-smart-log

包简介

Context-aware logging wrapper for Laravel applications

README 文档

README

Laravel SmartLog Logo

Laravel SmartLog

Context-aware logging wrapper for Laravel applications.

Latest Version on Packagist Total Downloads License

SmartLog solves a common problem in Laravel CLI development: You want visual feedback in your terminal (colors, progress), but you don't want to clutter your production log files (laravel.log, Sentry, Slack) with developer noise.

SmartLog intelligently routes your messages based on context (CLI vs. Web) and configuration.

Installation

composer require aaix/laravel-smart-log

Usage

Use SmartLog anywhere in your code. It automatically detects if it's running inside an Artisan command or a web request.

use Aaix\SmartLog\SmartLog;

// 1. Standard Output (CLI: White | File: Ignored)
// Perfect for progress bars, raw data dumps, or steps.
SmartLog::log('Importing users step 1 of 5...');

// 2. Developer Output (CLI: Gray | File: Ignored)
// Subtle output for debugging.
SmartLog::debug('Memory usage: 12MB');

// 3. Operational Info (CLI: Cyan | File: Ignored by default)
// Good for status updates that don't need permanent storage.
SmartLog::info('User 123 imported successfully.');
SmartLog::success('All operations finished.'); // Alias for info with green color

// 4. Issues (CLI: Yellow/Red | File: LOGGED)
// These are automatically sent to your default log channel (File, Sentry, etc.)
SmartLog::warning('API rate limit approaching.');
SmartLog::error('Connection failed, retrying...');

// 5. Block Styles (CLI: Large Blocks | File: LOGGED)
// Visually dominant blocks for critical start/stop events.
SmartLog::successBlock('DEPLOYMENT COMPLETE');
SmartLog::errorBlock('CRITICAL SYSTEM FAILURE');

How it works

Method CLI Output (Visual) Log File (Persistence)
log() White text ❌ (Ignored)
debug() Gray text (subtle) ❌ (Ignored)
info() Cyan text ❌ (Ignored*)
success() Green text ❌ (Ignored*)
warning() Yellow text Logged (warning)
error() Red text Logged (error)

*Default configuration. You can enable persistence for info/debug levels in the config file.

Configuration

By default, only warning and error levels are written to the log file. Everything else remains visual-only in the console.

To change this, publish the configuration file:

php artisan vendor:publish --tag=smart-log-config

config/smart-log.php

return [
    'persist_levels' => [
        'error',
        'warning', 
        // Add 'info' here to save info() and success() calls to the log file
    ],
];

Web Context Behavior

If you use SmartLog within a Controller or Job (non-CLI):

  • Visual Output: Skipped (no echo or print).
  • Persistence: Respects the config. SmartLog::error() will log to the file. SmartLog::log() will do nothing.

Testing

Run the test command:

./vendor/bin/testbench smartlog:test

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固