fuel / core

Fuel PHP Framework - The core of the Fuel v1 framework
http://fuelphp.com
813 stars 345 forks source link

Logging::write() custom levels being converted to int #1863

Open casperwilkes opened 9 years ago

casperwilkes commented 9 years ago

In the documentation it states that you can use Log::write() to create you're own custom levels to log at.

// and finally, we create a log entry with a custom $level
Log::write('Link', 'More info on http://fuelphp.com/')

This does not work as of the current version. Currently, it's taking your custom level, checking against an array of predefined settings, if not found, and converting it to a notice. If you use leave the default threshold where it's set in the config file, the NOTICE threshold is too small, thus not getting logged.

This kind of defeats the purpose if you want to use your own levels. If you lower the threshold as a work around, you get a lot of unnecessary logging going on from the router class.

Please see: Fuel/Core/Classes/Log.php line 222:

if (is_string($level))
        {
            if ( ! $level = array_search($level, static::$levels))
            {
                $level = 250;   // can't map it, convert it to a NOTICE
            }
        }
WanWizard commented 9 years ago

I think that no longer works since we've switched to Monolog in v1.5, which uses fixed levels. We'll have to see how to retain this feature.

https://github.com/Seldaek/monolog/issues/103 suggests it will not be that simple.

casperwilkes commented 9 years ago

Yeah, I was looking around the file for a way to implement it. I ended up just lowering the threshold and commenting out the logging in the router class. That seems to work if you use the predefined Log Methods or pass the predefined constants to Log::write().