# mageprince/module-log-viewer

> Magento 2 Log Viewer Extension

`composer require mageprince/module-log-viewer`

Canonical URL: https://packagento.com/mageprince/module-log-viewer

## At a glance

- **Vendor**: mageprince (https://packagento.com/mageprince.md)
- **Latest version**: 1.0.9 — released 2026-05-30
- **Pricing**: Free
- **Package type**: Magento 2 module
- **Status**: active, accepting new buyers

## Installation

Packagento is licence-gated, so even free packages need a licence on a project before Composer can resolve them.

1. **Sign in or create an account** at https://packagento.com/customer/account/.

2. **Add the package to your account.** Open https://packagento.com/mageprince/module-log-viewer and complete the free checkout. A licence is minted automatically.

3. **Create or pick a project, then activate the licence on it.**
   - Projects represent the Magento installs you deploy to. Manage them at https://packagento.com/projects/.
   - Activate the new licence on the project you'll deploy this package to. Activation is what generates the Composer credentials scoped to that project.

4. **Add the project credentials to your Magento codebase.**

   Grab the project's public + private key from https://packagento.com/projects/ (open the project, then its Credentials tab), and add them to `auth.json`:

   ```json
   {
     "http-basic": {
       "packagento.com": {
         "username": "ppk_live_...",
         "password": "psk_live_..."
       }
     }
   }
   ```

   Add the Packagento Composer repository to `composer.json`:

   ```json
   {
     "repositories": [
       { "type": "composer", "url": "https://packagento.com" }
     ]
   }
   ```

5. **Install and apply.**

   ```bash
   composer require mageprince/module-log-viewer:*
   bin/magento setup:upgrade
   bin/magento setup:di:compile
   bin/magento cache:flush
   ```

## What it does

Magento 2 Log Viewer Extension

## README

Mageprince Log Viewer is a powerful admin utility that allows you to manage, monitor, and debug log files directly from the Magento Admin Panel — without needing to access the server or filesystem.

## ✅ Compatibility

<b>Magento Open Source:</b> 2.3.x - 2.4.x </br>

## ✨ Key Features

#### Log File List
- Browse all log files in `var/log/` directly from the admin panel
- Search log files by filename
- Sort by filename, file size, or last modified time
- Pagination support for large log directories

#### Log Viewer
- View the latest log lines with configurable line count
- **Load Previous Logs** — paginate backwards through the file without loading it all at once
- **Live Log** — auto-refreshes every 3 seconds to tail new entries in real time
- **Wrap Lines** toggle for better readability of long lines
- **Clear Log** — clears the current view without affecting the file on disk

#### Full-File Search
- Search across the **entire log file**, not just the visible lines — works on files of any size (including multi-GB logs)
- Returns the last 20 matching lines; click **Load Previous Logs** to page through earlier results

#### File Operations
- **Download** log files directly from the admin
- **Truncate** (clear file content) with confirmation prompt
- Role-based access control — download and delete can be independently restricted per admin role

#### ⚙️ Admin Configuration (`Stores → Configuration → MagePrince → Log Viewer`)
| Setting | Description |
|---|---|
| Enable | Toggle the entire module on or off |
| Lines to Show | Number of lines tailed per view (default 500) |
| Items Per Page | Log file list page size (default 10) |
| Default Sort Column | `name`, `size`, or `mod_time` |
| Default Sort Direction | `asc` or `desc` |
| Allow Delete | Show or hide the Truncate button |
| Allow Download | Enable or disable file download |

#### 🔒 Security
- Path traversal prevention — all file access is validated against `var/log/` using real path resolution
- Search query sanitisation — null bytes and control characters stripped before regex matching
- Role-based ACL with four granular resources: View, Download, Delete, Settings

## 🚀 Installation Instructions

#### 1. Install via Composer (Recommended)

```bash
composer require mageprince/module-log-viewer
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
```

#### 2. Manual Installation

Copy the contents of this repository to `app/code/Mageprince/LogViewer`, then run:

```bash
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
```

## 🤝 Contribution

Want to contribute to this extension? The quickest way is to <a href="https://help.github.com/articles/about-pull-requests/">open a pull request</a> on GitHub.

## 🛠 Support

If you encounter any problems or bugs, please <a href="https://github.com/mageprince/magento2-logviewer/issues">open an issue</a> on GitHub.

## 📸 Screenshots

<img width="3412" height="2164" alt="image" src="https://github.com/user-attachments/assets/af38b037-7841-48dd-9830-6d9030cfc0ba" />
<img width="3400" height="2154" alt="image" src="https://github.com/user-attachments/assets/d9ed8946-e27d-46a9-b808-1ff90c3e718e" />

## Recent Versions

| Version | Released |
|---|---|
| 1.0.9 | 2026-05-30 |
| 1.0.8 | 2026-05-11 |
| 1.0.7 | 2025-12-17 |
| 1.0.6 | 2025-11-22 |
| 1.0.5 | 2025-09-23 |
| 1.0.4 | 2025-09-12 |
| 1.0.3 | 2025-08-26 |
| 1.0.2 | 2025-08-19 |
| 1.0.1 | 2025-08-07 |
| 1.0.0 | 2025-07-18 |

## Quality

Latest release (1.0.9) fails the Packagento QA pipeline. Verdicts below are per-cell (Magento line × PHP version) for the matrixed tools, and run-once for the static / security tiers.


### Compatibility

Each Magento line is installed on its supported PHP versions, then the module is built (DI compile + static-content deploy). Cells show passed / failed / untested; staircase gaps render as `–`.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | Pass | Pass | – | – |
| 2.4.8 | – | Pass | Pass | – |
| 2.4.9 | – | – | Pass | Pass |


### Code Quality

Advisory checks against the module's source. Never affect the Compatibility verdict — a phpcs finding can't make a module incompatible.

#### Static Analysis

Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| PHPCS | Warning | 29 | 29 warnings (ruleset: Magento2) — 29 auto-fixable with phpcbf |
| PHPMD | Warning | 5 | 5 rule violations (MissingImport:2, ExcessiveClassComplexity:1, CyclomaticComplexity:1, NPathComplexity:1) |
| Cpd | Pass | 0 |  |
| Composer validate | Info | 1 | valid; 1 advisory note (composer validate --strict) |

#### PHPStan

Type-checks the module against a real Magento install. Re-runs per Magento + PHP version because resolvable symbols differ between releases.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | 25 | 25 | – | – |
| 2.4.8 | – | 25 | 25 | – |
| 2.4.9 | – | – | 25 | 25 |


### Tests

Unit and integration suites run per Magento + PHP cell. Test failures speak to the module's behaviour, not its compatibility with a line, so they're reported here separately.

#### Unit Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |

#### Integration Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |


### Security

Dependency-advisory audit (composer audit) plus a source malware scan. A malware detection fails the version outright.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| Composer audit | Pass | 0 |  |
| Malware scan | Pass | 0 |  |

## Licence and pricing

Free. A licence is still minted on checkout and bound to your project for Composer access — no payment step.

Refundable within 14 days of first purchase via https://packagento.com/account/refunds/.

## Install via Claude Code or any MCP client

The Packagento MCP server can run the licence + project + Composer steps above in one tool call:

```
purchase_and_install_packages(
  composer_names=["mageprince/module-log-viewer"],
  project_id="proj_xxx"
)
```

This handles cart, checkout, licence minting, project activation, and writes auth.json credentials. Connect a client with `claude mcp add packagento https://mcp.packagento.com`. Full setup at https://packagento.com/docs/mcp-setup.

## Vendor

mageprince is a Magento 2 vendor on Packagento. See https://packagento.com/mageprince.md for their full catalogue.

