use ObjectLog\Log; $log = new Log(); $log->info('This is an info message.'); $log->error('This is an error message.');
use ObjectLog\Log; use ObjectLog\Formatter\LineFormatter; use ObjectLog\Handler\StreamHandler; $log = new Log(); $log->setLevel(Log::DEBUG); $formatter = new LineFormatter(); $formatter->setFormat('%level_name%: %message%'); $stream = fopen('log.txt', 'a'); $handler = new StreamHandler($stream); $handler->setFormatter($formatter); $log->addHandler($handler); $log->debug('This is a debug message.');This example shows how to customize the log format and output destination. It creates a new log instance, sets the logging level to DEBUG, creates a LineFormatter instance with a custom log format, creates a StreamHandler instance with a file stream, attaches the handler to the log instance, and logs a debug message. Package library: ObjectLog (https://github.com/ateliee/object-log)