Skip to content

roadrunner-php/app-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

21 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Package for sending log messages to RoadRunner

PHP Version Require Latest Stable Version phpunit psalm Codecov Total Downloads

Requirements

Make sure that your server is configured with following PHP version and extensions:

  • PHP 8.1+

Installation

You can install the package via composer:

composer require roadrunner-php/app-logger

Usage

Such a configuration would be quite feasible to run:

rpc:
  listen: tcp://127.0.0.1:6001

logs:
  channels:
    app:
      level: info

Then you need to create an instance of RoadRunner\Logger\Logger

use Spiral\Goridge\RPC\RPC;
use RoadRunner\Logger\Logger;

$rpc = RPC::create('tcp://127.0.0.1:6001');
// or
$rpc = RPC::fromGlobals();
// or
$rpc = RPC::fromEnvironment(new \Spiral\RoadRunner\Environment([
    'RR_RPC' => 'tcp://127.0.0.1:6001'
]));

$logger = new Logger($rpc);

Available methods

debug, error, info, warning is RoadRunner logger, and log is stderr

/**
 * debug mapped to RR's debug logger
 */
$logger->debug('Debug message');

/**
 * error mapped to RR's error logger
 */
$logger->error('Error message');

/**
 * log mapped to RR's stderr
 */
$logger->log("Log message \n");

/**
 * info mapped to RR's info logger
 */
$logger->info('Info message');

/**
 * warning mapped to RR's warning logger
 */
$logger->warning('Warning message');
try Spiral Framework

License

The MIT License (MIT). Please see LICENSE for more information. Maintained by Spiral Scout.