定制 hikmadh/log 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

hikmadh/log

Composer 安装命令:

composer require hikmadh/log

包简介

A very lightweight logging module

README 文档

README

A very lightweight logging module that supports

  • Rest Api Logging
  • Elastic Search Logging
  • GraphQl Logging
  • RabbitMq Logging
  • Varnish Cache Tag Bans Logging

No Core files is overridden or modified. These logging are implemented using plugins.

Please note that, This extension is for debugging purpose only, Once enabled this extension will write all/partial request and response to the log file based on your configuration, So plz be advised that keeping this extension on enabled mode for a long time will fill up your disk space. Once the debugging is completed this needs to be disabled

To Install

For Magento Version >= 2.4.4

composer require hikmadh/magento-log
php bin/magento module:enable Hikmadh_Log
php bin/magento setup:upgrade

For Magento Version < 2.4.4

composer require hikmadh/magento-log 1.1.0
php bin/magento module:enable Hikmadh_Log
php bin/magento setup:upgrade

Supported Logging

  • Rest API Logging
  • ElasticSearch Logging

For Magento version less than 2.4.4 if you need support for GraphQl logging plz try the below (Note its not tested from my end you can give a try)

Warning : This package is not install able via Composer 1.x, please make sure you upgrade to Composer 2+.

Alternatively you can download from github as well https://github.com/hikmadhdinakaran/magento-log.git

API Logging

Provides an option to log all/specific api calls.

In most of our environment we use different third party services such as order management, product management, product search , shipping management etc. These services interact with Magento using Rest APi'S.

At times, it would become very difficult to identify the root cause if we face any problem with these services.

Moreover, if we are in headless environment primarily using rest apis it would be really hard to identify the root cause for certain issues.

Consider a scenario where add to cart is not working for a particular customer only.

To effectively debug this issue, we would require the post data, headers etc that is posted by that particular user.

This extension would help you in this scenario. It has the feature that we can log the api request that is made by a specific user.

Let see the complete features of this extension.

Rest API logging

Features

Enable or Disable Logging through Admin Configuration

Able to configure the api urls that needs to be logged using regular expression which will give endless opportunity to the developer to log a specific url

Few such ex are

  • Able to log all the API logs
  • Able to log logged in users API calls
  • Able to log guest user API calls
  • Able to log only a specific api calls such as custom api call, cart, CMS, Product, Order etc
  • Able to log a specific user api calls.
  • The API logs contain both the request and Response
  • The logs are made in a separate file
  • This extension doesn't override any CORE Api class.

This can be safely deployed in Production environment as its very lightweight.

Configuration

Stores -> Configuration -> Hikmadh Extensions -> API Logging

Enable API Logging : To Enable all/selected api calls

Regular Expression Patterns: Define the regular expression pattern to log selected urls, For more than one urls use next line.

Ex

V1/carts/9 : Matches all urls for quote ID 9 that contains V1/carts/9

V1/carts/(\d)* : Matches for all quotes

V1/checkoutcomupapi/getTokenList : Match a specific url

Elastic Search Logging

At times there might me a case where you need to find out exactly what data is being pushed to elastic search and what is the response that we receive. This extension will help you to do that. It will log all the request and response of Elasticsearch from Magento.

Configuration

Stores -> Configuration -> Hikmadh Extensions -> Elastic Search Logging

How it works

The implementation is not very complicated its quiet simple though.

Magento uses the third party api client "elasticsearch/elasticsearch" to interact with Elasticsearch. This Extension by default has the feature of logging the request and responses.

\Elasticsearch\Connections\Connection::logRequestSuccess

But while creating the instance of this elasticsearch model, Magento always set the logger to be NULL due to which the request never get logged. This extension through a plugin sets this logger to a custom logger, Due to which the requests and the response are logged.

GraphQl Logging

To log the GraphQl Request and Response.

Configuration

Stores -> Configuration -> Hikmadh Extensions -> Graphql Logging

Graphql logging

Features

  • Able to log GET/POST Requests or All Requests
  • Able to log Based on HTTP Header Values
  • Able to log Based on Query types
    • product : To log only the product query type
    • product,categories : To log both product and categories query types

RabbitMq Logging

To log the RabbitMq Messages that are send from Magento to RabbitMq Server or that are cosumed by Magento from RabbitMq.

Configuration

Stores -> Configuration -> Hikmadh Extensions -> RabbitMq Logging

RabbitMq logging

Features

  • Able to log Outgoing Messages (The Messages that are published to RabbitMq Server)
  • Able to log Incoming Messages (The messages that are consumed from RabbitMq Server)

Varnish Cache Tags Logging

To log the varnish purge cache tags, To know more on this please refer here

Configuration

Stores -> Configuration -> hikmadh Extensions -> Log Varnish Cache Purging Tags

Output

Once the Logging is enabled, The log data will be available in the below MAGE_ROOT/var/log/hikmadh-logging.log

hikmadh/log 适用场景与选型建议

hikmadh/log 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 12 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「admin」 「php」 「menu」 「ui」 「config」 「Settings」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 hikmadh/log 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 hikmadh/log 我们能提供哪些服务?
定制开发 / 二次开发

基于 hikmadh/log 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-12-05