PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of Mateo   Simple PHP Logger   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Simple PHP Logger
Log messages to storage implemented by streams
Author: By
Last change:
Date: 2 months ago
Size: 525 bytes
 

Contents

Class file image Download
<?php

declare (strict_types=1);

use
SimpleLogger\Logger;
use
SimpleLogger\streams\{CollectionStream, FileStream, StdoutStream};

require
__DIR__ . '/vendor/autoload.php';

$logger = new Logger(stream: new CollectionStream([
    new
StdoutStream(),
   
FileStream::async(__DIR__ . '/log.log'),
]));

$logger->info('This is an info message', ['exception' => new Exception('This is an exception')]);
$logger->warning('This is a warning message');
$logger->debug('This is a debug message with {msg}', ['msg' => 'parameters']);