$driver)); // Initialize the driver $driver = new $driver(array_merge(Kohana::config('log'), Kohana::config('log_'.$driver_name))); // Validate the driver if ( ! ($driver instanceof Log_Driver)) throw new Kohana_Exception('%driver% does not implement the Log_Driver interface', array('%driver%' => $driver)); Kohana_Log::$drivers[] = $driver; } // Always save logs on shutdown Event::add('system.shutdown', array('Kohana_Log', 'save')); } Kohana_Log::$messages[] = array('date' => time(), 'type' => $type, 'message' => $message); } /** * Save all currently logged messages. * * @return void */ public static function save() { if (empty(Kohana_Log::$messages)) return; foreach (Kohana_Log::$drivers as $driver) { // We can't throw exceptions here or else we will get a // Exception thrown without a stack frame error try { $driver->save(Kohana_Log::$messages); } catch(Exception $e){} } // Reset the messages Kohana_Log::$messages = array(); } }