statamic / v2-hub

Statamic 2 - Feature Requests and Bug Reports
https://statamic.com
95 stars 5 forks source link

Log file created with tomorrow's date #458

Closed edalzell closed 7 years ago

edalzell commented 8 years ago

Steps to reproduce

  1. Make Statamic generate an error, and therefore an error log
  2. Look at the file name

    Expected behaviour

Filename should have todays date

Actual behaviour

logs 2016-02-19 20-31-40

edalzell commented 8 years ago

My timezone is set properly

phpinfo 2016-02-19 20-42-03

jasonvarga commented 8 years ago

Is your timezone set in system.yaml ?

edalzell commented 8 years ago

Yes, timezone: America/Vancouver

edalzell commented 8 years ago

Looks fine right now.

edalzell commented 8 years ago

Happening on my live site

edalzell commented 8 years ago

Regarding #927, if I set the timezone in my settings, the actually message is timestamped correctly but the file is created incorrectly.

Which means, that if I don't have the timezone set it is NOT using the right PHP default, which should be date.timezone.

edalzell commented 8 years ago

I don't have the timezone set in my system.yaml and your boot loader uses that:

        // Set the timezone. Override Laravel's config, and set in PHP
        config(['app.timezone' => Config::get('system.timezone')]);
        date_default_timezone_set(config('app.timezone'));
edalzell commented 7 years ago

This still occurs for me...

jackmcdade commented 7 years ago

Alrighty.

edalzell commented 7 years ago

See name of file and screenshot.

statamic-2017-02-02.log.zip

edalzell commented 7 years ago

system yaml - v2 - sitesv2 2017-02-01 20-38-05

edalzell commented 7 years ago

OK more debugging:

   protected function registerStreamHandler($config)
    {
        dd(date_default_timezone_get());

Produces UTC. So this is being called either before the boot loader that sets it, or, default timezone gets reset by the time it's called here.

edalzell commented 7 years ago

Yup, Logging is done in app.php, line 68:

$app->configureMonologUsing(function($monolog) {
    new Statamic\Logging\LoggingHandler($monolog);
});

Which I suspect is before this gets called:

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     */
    public function boot()
    {
        // Set the site's locale
        site_locale(LOCALE);

        // Set the timezone. Override Laravel's config, and set in PHP
        config(['app.timezone' => Config::get('system.timezone')]);
        date_default_timezone_set(config('app.timezone'));
edalzell commented 7 years ago

Just move this code:

       // Set the timezone. Override Laravel's config, and set in PHP
        config(['app.timezone' => Config::get('system.timezone')]);
        date_default_timezone_set(config('app.timezone'));

To app.php.

jackmcdade commented 7 years ago

Unfortunately I spoke too soon. It's not working yet...

jasonvarga commented 7 years ago

I could never replicate the behavior of the future logs, but at the location in @edalzell 's comment, the right timezone is now reflected.

edalzell commented 7 years ago

for you @jasonvarga, you'd have to have no log file and try it after 7pm your time I think, in order to get the next days date.