dotkernel / api

DotKernel's PSR-7 REST style API built around the Mezzio API skeleton.
https://docs.dotkernel.org/api-documentation/
MIT License
35 stars 5 forks source link

Error log filename not correct #6

Closed d3aq closed 3 years ago

d3aq commented 4 years ago

Because writer stream is specified in ./config/autoload/error-handling.global.php sprintf('%s/../../log/error-log-%s.log', __DIR__, date('Y-m-d')) it will be cached in ./data/cache/config-cache.php and the date() in filename it will remain the date when config-cache.php was created.

arhimede commented 4 years ago

Probably need to be fixed in https://github.com/dotkernel/dot-errorhandler package too.

gabidj commented 4 years ago

Cache cannot hold a value that changes, it must be rewritten. The name will change when the cache will expire.

You can use a ConfigProvider, but the generated value will still be cached so it doesn't really help.

The purpose of the date added in the file name is to prevent overwriting old but possibly important logs.

Below a simple example attempting to store a closure so when cache key is directly read the value should change.

<?php

$value = 'x';
$function = function(){ return chr(rand(65,90)); }; // random letter

// storing a value
apcu_store('value', $value);
// storing the function RESULT
apcu_store('functionValue', $function());

try {
    // attempting to store the function behaviour
    apcu_store('function', $function);
} catch (\Exception $e) {
    echo 'Error: ' . $e->getMessage(). "\n";
}

echo apcu_fetch('value');
echo apcu_fetch('functionValue');