定制 perspectiveteam/module-smartlog 二次开发

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

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

perspectiveteam/module-smartlog

Composer 安装命令:

composer require perspectiveteam/module-smartlog

包简介

AI-powered Magento 2 log analysis with semantic & keyword search. Uses LLPhant + OpenSearch for embeddings and vector storage. Supports OpenAI, Google Gemini, and Voyage AI providers.

README 文档

README

Semantic & keyword search across var/log/** and var/report/** using LLPhant embeddings + OpenSearch vector storage.

Features

  • Hybrid search — keyword (exact IDs, error codes) + semantic (natural language queries)
  • Multiple AI providers — OpenAI, Google Gemini, Voyage AI
  • Admin UI — search page at System > SmartLog
  • CLIbin/magento smartlog:index with progress bar
  • Recursive log scanning — reads all var/log/**/*.log and var/report/**/*
  • Isolated dependencies — LLPhant runs in a separate PHP process to avoid PSR/autoloading conflicts with Magento 2

Requirements

  • Magento 2.4.x (Commerce or Open Source)
  • PHP 8.1+
  • OpenSearch (uses Magento's native catalog/search connection)
  • API key for one of: OpenAI, Google Gemini, or Voyage AI

Installation

Via Composer (recommended)

composer require perspectiveteam/module-smartlog
bin/magento module:enable Perspective_SmartLog
bin/magento setup:upgrade
bin/magento setup:di:compile

Worker dependencies are installed automatically during setup:upgrade via Setup/Recurring.php, which runs on every setup:upgrade — including pipeline deploys that rebuild the filesystem from scratch. If automatic installation fails (e.g. Composer not available in the execution context), run manually:

bin/magento smartlog:install-worker

Manual (app/code)

  1. Copy the module to app/code/Perspective/SmartLog/
  2. Enable the module and run setup — worker installs automatically:
    bin/magento module:enable Perspective_SmartLog
    bin/magento setup:upgrade
    bin/magento setup:di:compile
  3. If automatic worker install failed:
    bin/magento smartlog:install-worker

Configuration

Go to Stores > Configuration > Perspective > SmartLog:

Setting Description
Enable Enable/disable the module
Embedding Provider OpenAI / Google Gemini / Anthropic (Voyage AI)
API Key Your provider API key
Model Embedding model (per provider)
Chunk Size Number of log entries per chunk (default: 15)
Batch Size Chunks per embedding API call (default: 20)
OpenSearch Index Index name for vectors (default: smartlog_vectors)
OpenSearch connection settings are read from Magento's native Catalog > Search configuration.

Usage

CLI Indexing

# Index all logs (respects enabled/disabled setting)
bin/magento smartlog:index
# Force index even if disabled
bin/magento smartlog:index --force

Admin Search

Navigate to System > SmartLog — search with:

  • Natural language: "was there a shipping address problem recently?"
  • Exact values: "40915" (order ID), "SQLSTATE" (error code)
  • Date filtering available

Architecture

Perspective/SmartLog/
├── Block/Adminhtml/          # Admin UI block
├── Composer/                 # Composer post-install script (WorkerInstaller)
├── Console/Command/          # CLI commands (smartlog:index, smartlog:install-worker)
├── Controller/Adminhtml/     # Admin controllers (search, reindex)
├── Model/
│   ├── Config.php            # System configuration reader
│   ├── Config/Source/        # Admin dropdown source models
│   ├── Indexer.php           # Orchestrates log reading + worker calls
│   ├── LogReader.php         # Recursive log file reader + chunker
│   ├── SearchService.php     # Search orchestration + date filtering
│   └── WorkerBridge.php      # proc_open bridge to worker.php
├── Setup/
│   └── Recurring.php         # Auto-installs worker on every setup:upgrade
├── Worker/
│   ├── composer.json         # Isolated LLPhant + OpenSearch deps
│   ├── install.sh            # Dependency installer (fallback)
│   └── worker.php            # Standalone process (embeddings + vector ops)
├── etc/                      # Magento XML configs
└── view/adminhtml/           # Admin layout, templates, CSS

Why a separate worker process?

LLPhant requires psr/log v3 and psr/http-message v2, which conflict with Magento 2's v1 copies. Instead of fighting autoloader isolation, the module runs LLPhant in a completely separate PHP process (Worker/worker.php), communicating via JSON over stdin/stdout.

Worker installation flow

  1. Primarybin/magento setup:upgrade triggers Setup/Recurring.php (runs on every upgrade) → WorkerInstaller::install() copies worker files to <magento-root>/lib/smartlog/ and runs composer install. Works correctly after every pipeline deploy, even if lib/smartlog/ was wiped.
  2. Fallback — if the recurring step fails (e.g. no Composer in path), a warning is logged and you can finish manually: bin/magento smartlog:install-worker.

License

MIT License. See LICENSE.md for details.

perspectiveteam/module-smartlog 适用场景与选型建议

perspectiveteam/module-smartlog 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 31 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 perspectiveteam/module-smartlog 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-31