<?php

namespace Tests\Concerns;

use DateTime;
use Monolog\Logger;

/**
 * Trait CanProvideLogRecord
 *
 * @package     Tests\Concerns
 * @author      Oanh Nguyen <oanhnn.bk@gmail.com>
 * @license     The MIT license
 */
trait CanProvideLogRecord
{
    /**
     * Make a simple log record
     *
     * @param  int|string $level   The log level
     * @param  string     $message The log message
     * @param  array      $context The log context
     * @return array
     */
    protected function logRecord($level = Logger::WARNING, $message = 'test', $context = []): array
    {
        $level = Logger::toMonologLevel($level);

        return [
            'message' => $message,
            'context' => $context,
            'level' => $level,
            'level_name' => Logger::getLevelName($level),
            'channel' => 'test',
            'datetime' => DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true))),
            'extra' => [],
        ];
    }
}

{'avg_line_length': 24.575, 'max_line_length': 99, 'alphanum_fraction': 0.5493387589013224, 'licenses': ['MIT'], 'repository_name': 'oanhnn/laravel-social-authenticate', 'path': 'tests/Concerns/CanProvideLogRecord.php', 'size': 983, 'lang': 'PHP'}