dnj/laravel-error-tracker-server 问题修复 & 功能扩展

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

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

dnj/laravel-error-tracker-server

最新稳定版本:v1.0.1

Composer 安装命令:

composer require dnj/laravel-error-tracker-server

包简介

README 文档

README

Packagist Dependency Version GitHub all releases GitHub GitHub Workflow Status

Introduction

This package is specifically built for laravel error tracking.

Installation

Require this package with composer.

composer require dnj/laravel-error-tracker-server

Laravel uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.

Copy the package config to your local config with the publish command:

php artisan vendor:publish --provider="dnj\ErrorTracker\Laravel\Server\ServiceProvider"

Config file

<?php

return [
    // Define your user model class for connect entities to users.
    'user_model' => \dnj\AAA\Models\User::class,

    'routes' => [
        'enable' => true,
        'prefix' => 'log', // example: log, device, etc ... , 
    ],
];

ℹ️ Note

User activity logs are disabled by default, if you want to save them set $userActivityLog to true.

Example :

use dnj\ErrorTracker\Contracts\IAppManager;
use dnj\ErrorTracker\Contracts\IDeviceManager;
use dnj\ErrorTracker\Contracts\ILogManager;
use dnj\ErrorTracker\Contracts\LogLevel;

$appManager = app(IAppManager::class);

$app = $appManager->store(
  title: 'Android mobile app',
  owner: 1,
  meta: ['key' => 'value']),
  userActivityLog: false,
);

$deviceManager = app(IDeviceManager::class);

$device = $deviceManager->store(
  title: 'Nokia mobile',
  owner: 1,
  meta: ['serialNo' => 44514526985]),
  userActivityLog: false,
);


$logManager = app(ILogManager::class);

$log = $logManager->store(
  app: $app,
  device: $device,
  level: LogLevel::INFO,
  message: 'App just installed',
  data: ['version' => "1.0.0"]
);

Working With Application:

  • Search Applications:
use dnj\ErrorTracker\Contracts\IAppManager;

$appManager = app(IAppManager::class);

$apps = $appManager->search(
  filters: [
    'title' => 'mobile app'
    'owner' => 2
  ],
);
  • Create new Application:
use dnj\ErrorTracker\Contracts\IAppManager;

$appManager = app(IAppManager::class);

$app = $appManager->store(
  title: 'Android mobile app',
  owner: 1,
  meta: ['key' => 'value']),
  userActivityLog: false,
); 
  • Update Application:
use dnj\ErrorTracker\Contracts\IAppManager;

$appManager = app(IAppManager::class);

$app = $appManager->update(
  app: 1,
  changes: [
    'title' => 'new title',
    'owner' => 2,
  ],
  userActivityLog: true,
); 
  • Delete application:
use dnj\ErrorTracker\Contracts\IAppManager;

$appManager = app(IAppManager::class);

$appManager->destroy(
  log: 1,
  userActivityLog: false,
);

Working With Device:

  • Search Device:
use dnj\ErrorTracker\Contracts\IDeviceManager;

$deviceManager = app(IDeviceManager::class);

$devices = $deviceManager->search(
  filters: [
    'title' => 'Nokia Mobile'
    'owner' => 2
  ],
);
  • Create new device:
use dnj\ErrorTracker\Contracts\IDeviceManager;

$deviceManager = app(IDeviceManager::class);

$device = $deviceManager->store(
  title: 'Nokia mobile',
  owner: 1,
  meta: ['key' => 'value']),
  userActivityLog: false,
); 
  • Update Device:
use dnj\ErrorTracker\Contracts\IDeviceManager;

$deviceManager = app(IDeviceManager::class);

$device = $deviceManager->update(
  device: 3,
  changes: [
    'title' => 'My Nokia Mobile',
    'owner' => 2,
    'meta' => ['serialNo' => 55245252]
  ],
  userActivityLog: true,
); 
  • Delete application:
use dnj\ErrorTracker\Contracts\IDeviceManager;

$deviceManager = app(IDeviceManager::class);

$deviceManager->destroy(
  log: 3,
  userActivityLog: false,
);

Working With Log:

  • Search Device:
use dnj\ErrorTracker\Contracts\ILogManager;
use dnj\ErrorTracker\Contracts\LogLevel;

$logManager = app(ILogManager::class);

$logs = $logManager->search(
  filters: [
    'apps' => [1,2],
    'devices' => [1],
    'levels' => [LogLevel::DEBUG],
    'message' => 'important flag',
    'unread' => true,
  ]
);
  • Create new log:
use dnj\ErrorTracker\Contracts\ILogManager;
use dnj\ErrorTracker\Contracts\LogLevel;

$logManager = app(ILogManager::class);

$log = $logManager->store(
  app: 1,
  device: 1,
  level: LogLevel::INFO,
  message: 'App has been started',
);
  • Mark as read log:
use dnj\ErrorTracker\Contracts\ILogManager;
use dnj\ErrorTracker\Contracts\LogLevel;

$logManager = app(ILogManager::class);

$log = $logManager->markAsRead(
  log: 44,
  user: 3
);
  • Mark as unread log:
use dnj\ErrorTracker\Contracts\ILogManager;
use dnj\ErrorTracker\Contracts\LogLevel;

$logManager = app(ILogManager::class);

$log = $logManager->markAsUnread(
  log: 44,
);
  • Delete log:
use dnj\ErrorTracker\Contracts\ILogManager;

$logManager = app(ILogManager::class);

$logManager->destroy(
  log: 44,
  userActivityLog: true,
);

Testing

You can run unit tests with PHP Unit:

./vendor/bin/phpunit

Contribution

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Security

If you discover any security-related issues, please email security@dnj.co.ir instead of using the issue tracker.

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固