/**
  * Add a new message to the log.
  *
  * @param   string  type of message
  * @param   string  message text
  * @return  void
  */
 public static function add($type, $message)
 {
     // Make sure the drivers and config are loaded
     if (!is_array(Kohana_Log::$config)) {
         Kohana_Log::$config = Kohana::config('log');
     }
     if (!is_array(Kohana_Log::$drivers)) {
         foreach ((array) Kohana::config('log.drivers') as $driver_name) {
             // Set driver name
             $driver = 'Log_' . ucfirst($driver_name) . '_Driver';
             // Load the driver
             if (!Kohana::auto_load($driver)) {
                 throw new Kohana_Exception('Log Driver Not Found: %driver%', array('%driver%' => $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);
 }