Skip to content

The Artex Logger is a lightweight, PSR-3-compliant logging library for PHP. It’s designed to provide a straightforward solution for logging with support for custom log writers, structured logs (like JSON), and configurable log levels. Ideal for projects of any size, the library ensures flexibility while keeping things simple.

License

Notifications You must be signed in to change notification settings

artex-agency/artex-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Artex Agency Logo
LOGGER
FAST PSR-3 LOGGER

Artex Logger is a lightweight, high-performance PHP logging library that adheres to PSR-3 standards, making it highly compatible with existing frameworks. It provides structured logging, supports log rotation, and offers optional asynchronous logging to ensure minimal performance impact.

 

Latest Version Total Downloads License

 

Key Features

  • Lightweight & High-Performance: Minimal overhead, designed for speed.
  • PSR-3 Compliant: Fully compatible with existing logging frameworks.
  • Structured Logging: Supports JSON and customizable log formats.
  • Log Rotation: Prevents uncontrolled growth of log files.
  • Asynchronous Logging: Optional non-blocking log writing.

 


 

Installation

composer "require artex/exceptions"

 

Usage

Basic Example

use Artex\Exceptions\ArtexRuntimeException;

try {
    throw new ArtexRuntimeException("Something went wrong!", 500);
} catch (ArtexRuntimeException $e) {
    echo $e->getMessage();
}

Adding Context to Exceptions

use Artex\Exceptions\ArtexException;

try {
    throw new ArtexException(
        "Validation failed!",
        422,
        ['field' => 'email', 'error' => 'Invalid format']
    );
} catch (ArtexException $e) {
    // Access additional context
    var_dump($e->getContext());
}

Extending Exceptions

You can easily extend any Artex exception to create project-specific exceptions:

namespace MyApp\Exceptions;

use Artex\Exceptions\ArtexRuntimeException;

class CustomException extends ArtexRuntimeException
{
    public function __construct(string $message = "", int $code = 0, array $context = [])
    {
        parent::__construct($message, $code, $context);
    }
}

Logging Exceptions

The library can seamlessly log exceptions if a PSR-3 compatible logger is available:

use Artex\Exceptions\ArtexRuntimeException;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

// Set up a PSR-3 logger
$logger = new Logger('example');
$logger->pushHandler(new StreamHandler('php://stdout', Logger::DEBUG));

// Register the logger
ArtexRuntimeException::registerLogger($logger);

try {
    throw new ArtexRuntimeException("Critical failure", 500);
} catch (ArtexRuntimeException $e) {
    // Exception is automatically logged
    echo "Exception logged: " . $e->getMessage();
}

 

Available Exceptions

The library ships with the following prebuilt exceptions:

Exception Class Description
ArtexException Base exception class for all custom exceptions.
ArtexRuntimeException For runtime errors.
ArtexInvalidArgumentException For invalid arguments passed to functions.
ArtexLogicException For logical errors in the application.
ArtexUnexpectedValueException For unexpected values in operations.
ValidationException For validation-specific errors.
DatabaseException For database-related errors.
FileException For file-related errors.

 

Advanced Usage

Extending Exceptions

You can easily extend any Artex exception to create project-specific exceptions:

namespace MyApp\Exceptions;

use Artex\Exceptions\ArtexRuntimeException;

class CustomException extends ArtexRuntimeException
{
    public function __construct(string $message = "", int $code = 0, array $context = [])
    {
        parent::__construct($message, $code, $context);
    }
}

 

Requirements

  • PHP 8.0 or higher

 


 

Contributing

We welcome contributions to the Artex Standard Exceptions Library! If you have an idea, feature request, or find a bug, please open an issue or submit a pull request.

 

LICENSE

This software is distributed under the Apache 2.0 License, granting you the freedom to use, modify, and distribute the software, provided you adhere to the terms outlined in the license.

See the LICENSE file for details.

 

FOLLOW US

X/Twitter      GitHub      LinkedIn

 

COPYRIGHT © 2025 ARTEX AGENCY INC.

About

The Artex Logger is a lightweight, PSR-3-compliant logging library for PHP. It’s designed to provide a straightforward solution for logging with support for custom log writers, structured logs (like JSON), and configurable log levels. Ideal for projects of any size, the library ensures flexibility while keeping things simple.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages