Search by

farhanchoksi / laravel-pretty-logger

Farhanchoksi

Laravel Pretty Logger — a pretty_dio_logger style HTTP request/response logger for Laravel: colored, boxed terminal output (and a readable file log) with automatic secret masking.

Package info

github.com/Farhanchoksi/laravel-pretty-logger

pkg:composer/farhanchoksi/laravel-pretty-logger

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.1 2026-10-20 10:51 UTC

This package is auto-updated.

Last update: 2026-10-20 11:02:29 UTC


README

A pretty_dio_logger-style HTTP request/response logger for Laravel. Every request prints a clean, colored, boxed summary to your terminal (and/or a readable log file) — with passwords, OTPs, tokens and cookies automatically masked.

  • Package: farhanchoksi/laravel-pretty-logger
  • Namespace: Farhanchoksi\PrettyLogger
  • Config file: config/pretty-logger.php
┌───────────────────────────────────────────────
│ REQUEST  POST  http://localhost:8000/login
├───────────────────────────────────────────────
│ body: {"phone":"9876543210","password":"******"}
│ headers: content-type: application/x-www-form-urlencoded
└───────────────────────────────────────────────
┌───────────────────────────────────────────────
│ RESPONSE  200  POST  http://localhost:8000/login
├───────────────────────────────────────────────
│ duration: 22ms
│ headers: content-type: text/html; charset=utf-8
│ set-cookie: <redacted>
│ body: <html document, 5,855 bytes — body hidden>
└───────────────────────────────────────────────

Install

composer require farhanchoksi/laravel-pretty-logger

The service provider is auto-discovered — no registration needed. The logger activates automatically when APP_DEBUG=true.

Optional: publish the config

php artisan vendor:publish --tag=pretty-logger-config

This creates config/pretty-logger.php so you can customize everything.

Configuration (.env)

Key Default Meaning
PRETTY_LOGGER (null = follow APP_DEBUG) Force the logger true/false regardless of debug mode.
PRETTY_LOGGER_TERMINAL true Stream colored boxes to php://stderr (terminal).
PRETTY_LOGGER_FILE true Also append to storage/logs/http.log.
PRETTY_LOGGER_HTML_BODY false Print HTML response bodies (truncated). Off = just byte size.
PRETTY_LOGGER_MAX_BODY 600 Max characters of a JSON/text body to print.

Tip: to keep logging on in production without turning APP_DEBUG on, set APP_DEBUG=false and PRETTY_LOGGER=true.

Security

The logger masks sensitive data by default (configurable in config/pretty-logger.php):

  • Body/query keys → password, password_confirmation, token, secret, otp, api_key, access_token, refresh_token → ******
  • Headers → cookie, set-cookie, authorization, x-csrf-token, x-xsrf-token → <redacted>
  • URLs → any masked key appearing as a query param is redacted too
  • HTML/binary response bodies are summarized, not dumped

Requirements

  • PHP 8.2+
  • Laravel 10, 11, 12 or 13

License

MIT