sudo/monitoring-logs

Sudo monitor log package

v1.1.1 2022-06-28 07:50 UTC

This package is auto-updated.

Last update: 2024-03-28 11:59:17 UTC


README

Giới thiệu: Đây là package dùng để ghi log vào Hệ thống giám sát tác vụ Sudo.

Mặc định package giúp gửi log về cho Hệ thống giám sát tác vụ Sudo để tiện theo dõi

Cài đặt để sử dụng

Chạy các lệnh:

composer require sudo/monitoring-logs

php artisan vendor:publish --provider="Sudo\MonitoringLog\Providers\SudoMonitoringLogServiceProvider"

Cấu hình tham số

Tại config/SudoMonitoringLog.php sẽ có nội dung như sau:

return [
    'host' => env('MONITORING_LOG_HOST', 'https://monitoring.sudo.vn'),
    'token' => env('MONITORING_LOG_TOKEN', ''),
];

Cần sửa 2 tham số tại .env:

  • MONITORING_LOG_HOST: Host hệ thống giám sát. Mặc định: https://monitoring.sudo.vn
  • MONITORING_LOG_TOKEN: Token truy cập API mà hệ thống giám sát cung cấp

SudoMonitoringLog API

Các function ghi log được tích hợp sẵn tại class SudoMonitoringLog:

  1. Ghi log khi job thực hiện thành công:

    /**
     * Ghi trạng thái log thành công
     * @param integer $job_item_id       ID job trên hệ thống giám sát
     * @param string  $message           Nội dung cần thông báo
     * @param string  $title_link        Link khi click vào thông báo
     */
    SudoMonitoringLog::success($job_item_id, $message, $title_link="")
  2. Ghi log khi job thực hiện xảy ra lỗi:

    /**
     * Ghi trạng thái log lỗi
     * @param integer $job_item_id       ID job trên hệ thống giám sát
     * @param string  $message           Nội dung cần thông báo
     * @param string  $title_link        Link khi click vào thông báo
     */
    SudoMonitoringLog::error($job_item_id, $message, $title_link="")