gokhankurtulus/logger 问题修复 & 功能扩展

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

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

gokhankurtulus/logger

最新稳定版本:1.0.0

Composer 安装命令:

composer require gokhankurtulus/logger

包简介

A simple PHP library for logging.

README 文档

README

License: MIT PHP Version Release

A simple PHP library for logging.

Installation

You can install the library using Composer. Run the following command:

composer require gokhankurtulus/logger

Usage

use Logger\Logger;

Logger::setFolderPath(__DIR__ . DIRECTORY_SEPARATOR . 'Logs');
Logger::setFileName('app.log');
Logger::iniSet(true, false, E_ALL);

Logger::log('this is app log message', 'this is log title');

Logs/app.log output:

[01-01-2024 15:00:00 - Europe/Istanbul] - this is log title
this is log message

Inheritance

You can inherit from Logger class if you want to categorize your logs. You must override the $folderPath and $fileName parameters for conflicts.

class PDOLogger extends \Logger\Logger
{
    protected static string $folderPath = "";
    protected static string $fileName = "";
}
use Logger\Logger;

Logger::setFolderPath(__DIR__ . DIRECTORY_SEPARATOR . 'Logs');
Logger::setFileName('app.log');

// for log_errors, display_errors, error_reporting and
// error_log will be Logger::getFolderPath() . DIRECTORY_SEPARATOR . Logger::getFileName()
Logger::iniSet(true, false, E_ALL);

// You can give specific path for classes,
// by default it will be Logger's folder path
PDOLogger::setFolderPath(__DIR__ . DIRECTORY_SEPARATOR . 'DBLogs');
PDOLogger::setFileName('pdo.log');

Logger::log('this is app log message', 'this is log title');
PDOLogger::log('this is pdo log message');

Logs/app.log output:

[01-01-2024 15:00:00 - Europe/Istanbul] - this is log title
this is app log message

DBLogs/pdo.log output:

[01-01-2024 15:00:00 - Europe/Istanbul] - 
this is pdo log message

Public Methods

Logger::log();
Logger::iniSet();
Logger::setFolderPath();
Logger::getFolderPath();
Logger::setFileName();
Logger::getFileName();

Securing the Logs

Log files may contain sensitive information such as database, credentials or other confidential data. It is important to secure the files and restrict access to prevent unauthorized exposure of this information. The security of your logs is your responsibility. However, please attention to the following steps;

  • Place the log folder outside the public web directory or in directory that is not directly accessible by the web server.
  • Set file permissions to ensure that only authorized users or processes can read the log files.
  • Add the log folder to your project's .gitignore file. This ensures that the file is not included in version control systems, preventing accidental exposure of sensitive information in your code repository.

License

Logger is open-source software released under the MIT License. Feel free to modify and use it in your projects.

Contributions

Contributions to Logger are welcome! If you find any issues or have suggestions for improvements, please create an issue or submit a pull request on the GitHub repository.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-01-04