<?php

use Apexl\Io\Logger\Enums\LogLevel;

$level = \Apexl\Io\env('LOG__GLOBAL_LEVEL', LogLevel::WARNING);
if (!$level instanceof LogLevel) {
    $level = LogLevel::from($level);
}

return [
    "level" => $level,
    "enable_dynamic_streams" => filter_var(\Apexl\Io\env('LOG__ENABLE_DYNAMIC_STREAMS', true), FILTER_VALIDATE_BOOL),
    "warn_about_dynamic_streams" => filter_var(\Apexl\Io\env('LOG__WARN_ABOUT_DYNAMIC_STREAMS', false), FILTER_VALIDATE_BOOL),
    "catch_errors" => filter_var(\Apexl\Io\env('LOG__CATCH_ERRORS', true), FILTER_VALIDATE_BOOL),
    'directory' => \Apexl\Io\env('LOG__DIRECTORY', 'log'),
    "streams" => [
        "default" => [
            "level" => \Apexl\Io\env('LOG__DEFAULT_LEVEL'),
            "handlers" => [
                [
                    "destination" => "file"
                ]
            ]
        ],
        "query" => [
            "level" => \Apexl\Io\env('LOG__QUERY_LEVEL'),
            "handlers" => [
                [
                    "destination" => "file"
                ]
            ]
        ],
        "error" => [
            "level" => \Apexl\Io\env('LOG__ERROR_LEVEL'),
            "handlers" => [
                [
                    "destination" => "error_log"
                ],
                [
                    "destination" => "file",
                    "file" => "error.log"
                ]
            ]
        ],
    ]
];
