nguyenanhung / my-debug
My Debug, Logger Library
Installs: 34 799
Dependents: 21
Suggesters: 7
Security: 0
Stars: 3
Watchers: 3
Forks: 2
Open Issues: 0
Requires
- php: >=8.1
- ext-json: *
- ext-mbstring: *
- monolog/monolog: ^3.0
- nguyenanhung/benchmark: ^2.0 || ^1.0
- nguyenanhung/filesystem-helper: ^2.0 || ^1.0
- nguyenanhung/slug-helper: ^3.0 || ^2.0 || ^1.0
Requires (Dev)
- kint-php/kint: >=3.0
Suggests
- ext-iconv: Needed to support ICONV
- ext-json: Needed to support JSON
- ext-mbstring: Needed to support MbString
- ext-openssl: Needed to support OpenSSL
- sentry/sdk: Need support for Logging with Sentry
- dev-master
- v4.x-dev
- v4.0.8
- v4.0.7
- v4.0.6
- v4.0.5
- v4.0.4
- v4.0.3
- v4.0.2
- v4.0.1
- v4.0.0
- v3.x-dev
- v3.1.3
- v3.1.2
- v3.1.1
- v3.1.0
- v3.0.9
- v3.0.8.6
- v3.0.8.5
- v3.0.8.4
- v3.0.8.3
- v3.0.8.2
- v3.0.8.1
- v3.0.8
- v3.0.7
- v3.0.6
- v3.0.5
- v3.0.4
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0.0
- v2.x-dev
- v2.1.4
- v2.1.3
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0.1
- v2.0.0
- v1.9.1
- v1.9.0
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0
- v0.1.4
- v0.1.3
- v0.1.2.12
- v0.1.2.11
- v0.1.2.10
- v0.1.2.9
- v0.1.2.8
- v0.1.2.7
- v0.1.2.6
- v0.1.2.5
- v0.1.2.4
- v0.1.2.3
- v0.1.2.2
- v0.1.2.1
- v0.1.2
- v0.1.1
- v0.1.0
- dev-v1.9.x-dev
This package is auto-updated.
Last update: 2024-11-21 19:32:32 UTC
README
My Debug
1 thư viện nhỏ hỗ trợ việc ghi log, benchmark ứng dụng PHP. Được customize lại cho phù hợp mục đích sử dụng
Version
- V1.x support all PHP version
>=5.6
- V2.x support all PHP version
>=5.6
- V3.x support all PHP version
>=7.0
- V4.x support all PHP version
>=8.1
Ngoài ra, gói cũng hỗ trợ logging lên service ngoài như Sentry, khi đó cần cài thêm gói sentry/sdk
như dưới đây
- sentry/sdk
^3.0 || ^2.0
Usage
Tham khảo hướng dẫn triển khai tại đây và trong thư mục test/
Debug & Logger
<?php require_once __DIR__ . '/../vendor/autoload.php'; require __DIR__ . '/func.php'; use nguyenanhung\MyDebug\Logger; // Test Content $logPath = __DIR__ . '/../tmp'; $logPath = realpath($logPath); $logSubPath = date('Y-m-d'); $logFilename = 'Log-' . date('Y-m-d') . '.log'; $name = 'Test'; $msg = 'Test Log lan 2'; $context = [ 'name' => 'Nguyen An Hung', 'email' => 'dev@nguyenanhung.com', 'website' => 'https://nguyenanhung.com', ]; // Call $logger = new Logger(); $logger->setDebugStatus(true); $logger->setGlobalLoggerLevel(); $logger->setLoggerPath($logPath); $logger->setLoggerSubPath($logSubPath); $logger->setLoggerFilename($logFilename); $logger->__construct(); echo "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"; echo "\n getVersion: " . $logger->getVersion() . "\n"; echo "\n setDebugStatus: " . $logger->getDebugStatus() . "\n"; echo "\n setLoggerPath: " . $logger->getLoggerPath() . "\n"; echo "\n setLoggerSubPath: " . $logger->getLoggerSubPath() . "\n"; echo "\n setLoggerFilename: " . $logger->getLoggerFilename() . "\n"; echo "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"; __show__($logger->debug($name, $msg . ' - DEBUG', $context)); __show__($logger->info($name, $msg . ' - INFO', $context)); __show__($logger->notice($name, $msg . ' - NOTICE', $context)); __show__($logger->warning($name, $msg . ' - WARNING', $context)); __show__($logger->error($name, $msg . ' - ERROR', $context)); __show__($logger->critical($name, $msg . ' - CRITICAL', $context)); __show__($logger->alert($name, $msg . ' - ALERT', $context)); __show__($logger->emergency($name, $msg . ' - EMERGENCY', $context));
Benchmark
<?php require_once __DIR__ . '/../vendor/autoload.php'; require __DIR__ . '/func.php'; use nguyenanhung\MyDebug\Benchmark; $benchmark = new Benchmark(); $benchmark->mark('code_start'); $mathFunctions = ["abs", "acos", "asin", "atan", "floor"]; $count = 10; for ($i = 0; $i < $count; $i++) { foreach ($mathFunctions as $key => $function) { $function($i); echo ($key + 1) . " -> " . $function . "\n"; } } $benchmark->mark('code_end'); __show__($benchmark->elapsed_time('code_start', 'code_end')); __show__($benchmark->memory_usage());
Manage File
<?php require_once __DIR__ . '/../vendor/autoload.php'; require __DIR__ . '/func.php'; use nguyenanhung\MyDebug\Manager\File; $file = new File(); $file->setExclude(array('*.zip')); $file->setInclude(array('*.log')); $path = __DIR__ . '/../tmp'; $path = realpath($path); __show__($file->directoryScanner($path));
Utils
<?php require_once __DIR__ . '/../vendor/autoload.php'; require __DIR__ . '/func.php'; use nguyenanhung\MyDebug\Utils; $utils = new Utils(); $str = 'Nguyễn An Hưng'; __show__($utils->getVersion()); __show__($utils::slugify($str));
Support
If any question & request, please contact following information
From Vietnam with Love <3