jmrashed/logger
最新稳定版本:v1.0.2
Composer 安装命令:
composer require jmrashed/logger
包简介
A lightweight, production-ready logging utility for development environments
README 文档
README
A lightweight, production-ready logging utility for development environments.
Requirements
- PHP 7.4 or higher
- Composer (recommended for installation)
Table of Contents
- Features
- Installation
- Usage
- Log Levels
- Log Format
- File Structure
- Configuration
- Testing
- Contributing
- License
- Security
Features
- Multiple log levels (DEBUG, INFO, WARNING, ERROR, CRITICAL)
- Automatic log rotation (10MB max, keeps 5 files)
- Context data support
- Thread-safe file writing
- Git-ignored log files
- PSR-4 autoloading
- Composer package support
- Comprehensive test suite
- GitHub Actions CI/CD
Installation
Via Composer (Recommended)
composer require jmrashed/logger
Manual Installation
Download the Logger.php file and include it in your project.
Usage
// Using Composer autoload require_once 'vendor/autoload.php'; // Or manual include require_once $_SERVER['DOCUMENT_ROOT'] . '/_Logger/Logger.php'; // Basic logging \DevLogger\Logger::info('User logged in'); \DevLogger\Logger::error('Database connection failed'); \DevLogger\Logger::warning('Deprecated function used'); // Logging with context \DevLogger\Logger::info('User action', ['user_id' => 123, 'action' => 'login']); \DevLogger\Logger::error('Query failed', ['query' => 'SELECT * FROM users', 'error' => $e->getMessage()]);
Log Levels
DEBUG- Detailed debug informationINFO- General information messagesWARNING- Warning messagesERROR- Error conditionsCRITICAL- Critical conditions
Log Format
[2024-01-15 14:30:25] [INFO] User logged in {"user_id":123,"action":"login"}
File Structure
_Logger/
├── Logger.php # Main logger class
├── example.php # Usage example
├── composer.json # Composer package configuration
├── phpunit.xml.dist # PHPUnit configuration
├── .gitignore # Git ignore rules
├── CHANGELOG.md # Change log
├── CODE_OF_CONDUCT.md # Code of conduct
├── CONTRIBUTING.md # Contributing guidelines
├── LICENSE # License file
├── README.md # This file
├── SECURITY.md # Security policy
├── .github/ # GitHub workflows and templates
├── docs/ # Documentation
│ ├── API.md # API documentation
│ └── INSTALL.md # Installation guide
└── tests/ # Test files
└── LoggerTest.php # Unit tests
Configuration
The logger automatically:
- Creates log directory if it doesn't exist
- Rotates logs when they exceed 10MB
- Keeps maximum 5 log files
- Uses thread-safe file writing
Testing
Run the test suite:
composer test
Contributing
Contributions are welcome! Please see our Contributing Guide for details.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Security
For security issues, please see our Security Policy.
Author
Md Rasheduzzzaman
- Email: jmrashed@gmail.com
- GitHub: @jmrashed
- Repository: https://github.com/jmrashed/logger
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-19