Download the PHP package tibbs/scoped-logger-laravel without Composer

On this page you can find all versions of the php package tibbs/scoped-logger-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package scoped-logger-laravel

Fine-grained logging level management for Laravel

CI (Format Checks, Type Checking and Tests) CodeCov Latest Version on Packagist Total Downloads

When troubleshooting specific issues in a Laravel application, it is often helpful to have increased logging visibility regarding a specific portion of your application. However, if you increase your log level, then you will also increase the log traffic from all other parts of the application at the same time. While logging channels offer some flexibility in separating different types of log entries, they are cumbersome and must all be pre-configured before they can be used.

This package adds the ability to define different logging levels based on the "scope" of a particular log entry. Scopes can be explicitly defined when logging, or automatically determined based on the calling class (via its name, a defined property, or a defined method). Logging levels for a given scope can be configured in the config/scoped-logger.php configuration file or overridden at runtime for debugging purposes.

Features

Requirements

Installation

Install the package via composer:

Publish the config file (optional):

Quick Start

Configure scopes in config/scoped-logger.php:

Use in your application:

Usage

Explicit Scopes

The most straightforward way to use scoped logging:

Automatic Scope Detection

Scoped Logger can automatically detect the scope from the calling class:

Scope Priority

Scopes are resolved in this order:

  1. Explicit scope - Log::scope('payment')
  2. Class FQCN - If the calling class FQCN is configured as a scope
  3. Class property/method - Static property $log_scope or method getLogScope()
  4. Default level - Falls back to default_level config

Pattern Matching

Use wildcard patterns to match multiple scopes with a single configuration:

Supported Wildcards:

Pattern Specificity:

When multiple patterns match a scope, the most specific pattern wins:

  1. Exact matches (no wildcards) are most specific
  2. Longer patterns are more specific than shorter ones
  3. Fewer wildcards make patterns more specific

Suppressing Scopes

Set a scope to false to completely suppress all logs from that scope:

Unknown Scope Handling

By default, using an unconfigured scope throws an exception. This helps catch typos and configuration mistakes:

You can configure how unknown scopes are handled:

Handling Options:

What counts as "known":

Environment Variable:

Configuration

Disabling Scoped Logging

You can completely disable scoped logging by setting SCOPED_LOG_ENABLED=false in your .env file. When disabled:

The same applies to individual channels listed in disabled_channels: they return a PassThroughScopedLogger, which implements the same ScopedLoggerContract as the active ScopedLogger.

Use this when:

Full Configuration Options

All available configuration options:

⚠️ Important: Channel Log Levels

The underlying Laravel channel log level acts as a floor for all logged events.

If you're using scoped logging on a channel, that channel should be configured with the lowest log level you need (typically debug), otherwise the channel will filter out logs that scoped logging passes along to record.

Example Problem

Solution

Set your channel to debug level and let scoped logging handle the filtering:

Now scoped logging has full control over what gets logged.

Why This Happens

Logging flows through two filters:

  1. Scoped Logger - Filters based on scope configuration
  2. Channel Driver - Filters based on channel level config

Both must allow the log through. The channel level is a hard floor that cannot be overridden by scoped logging.

Runtime Modification

Temporarily override scope levels at runtime without changing configuration:

Runtime overrides:

Conditional Logging

Use closures for dynamic log levels based on environment, time, feature flags, or any custom logic:

Closures are evaluated on each log call, allowing real-time adjustments based on current conditions.

Per-Channel Scope Configurations

Configure different log levels for the same scope across different channels:

Channel-specific scopes override global scopes. If a scope isn't defined for a channel, it falls back to the global configuration.

On-Demand Channels

Channels created with Log::stack() and Log::build() are filtered like configured channels and support scope(). They are matched against channel_scopes and disabled_channels by name:

Method Channel name
Log::stack($channels, 'audit') audit
Log::stack($channels) stack
Log::build($config) ondemand

Each call returns a new logger, so runtime overrides set with setRuntimeLevel() on another channel do not apply to it.

Multiple Scopes

Log with multiple scopes simultaneously by passing an array to scope(). The package uses a "most verbose wins" strategy:

Rules:

Debug Mode

Enable debug mode to see detailed scope resolution information in log context:

When enabled, each log entry includes:

⚠️ Warning: Debug mode adds overhead. Use only for troubleshooting scope resolution issues.

Artisan Commands

List all configured scopes

Options:

Default output displays:

Channel-specific output (--channel) displays:

Test scope resolution

Options:

Default output shows:

Channel-specific output (--channel) additionally shows:

All-channels output (--all-channels) shows:

Example output for --all-channels:

Performance

If your application logs a large number of entries (thousands), some caution may be warranted because of the unavoidable overhead that this filtering process adds to each log call. In real world applications, it is likely that the overhead associated with actually logging the entry will far exceed any overhead from filtering, but for those interested in eeking out every last inch of performance, strategies you can employ to minimize the performance impact include:

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of scoped-logger-laravel with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/contracts Version ^12.11.0 || ^13.0
spatie/laravel-package-tools Version ^1.16
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tibbs/scoped-logger-laravel contains the following files

Loading the files please wait ...