noumenia/libloggerphp
最新稳定版本:1.2
Composer 安装命令:
composer require noumenia/libloggerphp
包简介
libLoggerPHP is a logging library implementation in PHP.
README 文档
README
_ _ _ _ ____ _ _ ____
| (_) |__ | | ___ __ _ __ _ ___ _ __| _ \| | | | _ \
| | | '_ \| | / _ \ / _` |/ _` |/ _ \ '__| |_) | |_| | |_) |
| | | |_) | |__| (_) | (_| | (_| | __/ | | __/| _ | __/
|_|_|_.__/|_____\___/ \__, |\__, |\___|_| |_| |_| |_|_|
|___/ |___/
libLoggerPHP is a logging library implementation in PHP.
Features
- It is as simple as it gets
- Supports different destinations (console/null/syslog/array/file)
- Supports different priorities (emergency, alert, critical, error, warning, notice, info, debug)
- ANSI colors or no beautification
Requirements
- PHP 8.0, 8.1, 8.2, 8.3, 8.4, 8.5
Install with RPM packages
You may install libLoggerPHP via the copr repository, for Alma/Rocky/Oracle Enterprise Linux and Fedora, simply use:
dnf copr enable mksanthi/noumenia
dnf install libLoggerPHP
Install with Composer
You may install libLoggerPHP with composer, to get the latest version use:
composer require noumenia/libloggerphp
Install manually
Download the repository and copy the libLoggerPHP project directory in the appropriate place within your project or within an accessibe location, for example under /usr/share/php.
How to use
Load and initialize the library by loading the common.inc.php file:
require_once("/path/to/libLoggerPHP/controller/common.inc.php");
The call the setDestination function and pass it an appropriate destination, here is an example to log to syslog and to the console:
<?php
require_once("/path/to/libLoggerPHP/controller/common.inc.php");
use libLoggerPHP\Log;
use libLoggerPHP\LogDestinationSyslog;
use libLoggerPHP\LogDestinationConsole;
Log::setDestination(new LogDestinationSyslog(array('facility' => LOG_MAIL)), LOG_DEBUG);
Log::error("An error happened and will be logged to syslog");
Log::setDestination(new LogDestinationConsole(array()), LOG_DEBUG);
Log::warning("This is your warning and will be printed to STDOUT");
Design diagram
The following diagram shows a simplified view of the libLoggerPHP implementation.
+----------------+ +-------------------+
| | | |
| common.inc.php | +---+-> | constants.inc.php |
| | | | |
+----------------+ | +-------------------+
|
Constants | Set system constants
Autoloader |
|
| +----------------------------------------+
| | |
+-> | NoumenialibLoggerPHPAutoloader.inc.php |
| |
+----------------------------------------+
Define the autoloader function
+-------------------------+
| |
| LoggerInterface.inc.php |
implements | |
+-------------+ +--------> +-------------------------+
| |
| Log.inc.php | Abstract log destination interface
| |
+-------------+ +------+-> +----------------------------+
| | |
Event logging | | LogDestinationNull.inc.php | +----+
Display handler | | | |
| +----------------------------+ |
| |
| Log to null |
| |
| +-------------------------------+ |
| | | |
+-> | LogDestinationConsole.inc.php | +-+
| | | |
| +-------------------------------+ | +---------------------------------+
| |implements | |
| Log to console +---------> | LogDestinationInterface.inc.php |
| | | |
| +------------------------------+ | +---------------------------------+
| | | |
+-> | LogDestinationSyslog.inc.php | +--+ Abstract log destination interface
| | | |
| +------------------------------+ |
| |
| Log to syslog |
| |
| +-----------------------------+ |
| | | |
+-> | LogDestinationArray.inc.php | +---+
| | | |
| +-----------------------------+ |
| |
| Log to array |
| |
| +----------------------------+ |
| | | |
+-> | LogDestinationFile.inc.php | +----+
| |
+----------------------------+
Log to file
Related projects
- Aetolos - Virtual hosting at your... command line!
- guardian-milter - Multi-purpose security milter.
- bravos - Log file security parser.
- mmDbDaemon is a memory-resident MaxMind Database reader implementation in PHP.
- libMilterPHP is a Postfix/Sendmail Milter library implementation in PHP.
- libSDManagerPHP provides a portable daemon with a Sockets and Streams manager.
- libLoggerPHP is a logging library implementation in PHP.
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-only
- 更新时间: 2025-12-27