定制 qu1eeeoj/laravel-logger 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

qu1eeeoj/laravel-logger

Composer 安装命令:

composer require qu1eeeoj/laravel-logger

包简介

Logger with console logger

README 文档

README

This library provides the use of laravel logger along with the output of information to the console.

This package can be useful when running laravel commands

Installation

composer require qu1eeeoj/laravel-logger

Example

<?php

namespace App\Console\Commands;

use App\Models\User;
use Illuminate\Console\Command;
use Qu1eeeOJ\LaravelLogger\LoggerService;

class CreateUserCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'user:create {email}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Create user with admin privileges';

    /**
     * CreateUserCommand constructor
     *
     * @param LoggerService $logger - Logger with output console
     */
    public function __construct(private readonly LoggerService $logger = new LoggerService('daily'))
    {
        // Call parent constructor
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle(): int
    {
        // Create user
        $user = User::query()->create([]);
        $this->logger->info('User created successfully');

        // Adding admin privileges
        $user->permissions()->setRole('admin');
        $this->logger->info('Now user has admin privileges');

        return Command::SUCCESS;
    }
}

Methods - LoggerService

  • alert(string $message): void
  • critical(string $message): void
  • debug(string $message): void - works with the console, but in working mode it does not write information to the log, but only the console!
  • emergency(string $message): void
  • error(string $message): void - works with console
  • info(string $message): void - works with console
  • notice(string $message): void
  • warning(string $message): void - works with console
  • withConsoleLogger(): bool - Determine whether the console logger is used

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2023-01-09