Development

Changeset 6397

You must first sign up to be able to contribute.

Changeset 6397

Show
Ignore:
Timestamp:
12/09/07 19:44:53 (2 years ago)
Author:
fabien
Message:

added 2 options for sfFileLogger (closes #2145)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/log/sfFileLogger.class.php

    r5109 r6397  
    2727   * Available options: 
    2828   * 
    29    * - file: The file path or a php wrapper to log messages 
    30    *         You can use any support php wrapper. To write logs to the Apache error log, use php://stderr 
     29   * - file:      The file path or a php wrapper to log messages 
     30   *              You can use any support php wrapper. To write logs to the Apache error log, use php://stderr 
     31   * - dir_mode:  The mode to use when creating a directory (default to 0777) 
     32   * - file_mode: The mode to use when creating a file (default to 0666) 
    3133   * 
    3234   * @param  sfEventDispatcher A sfEventDispatcher instance 
     
    4547    if (!is_dir($dir)) 
    4648    { 
    47       mkdir($dir, 0777, true); 
     49      mkdir($dir, isset($options['dir_mode']) ? $options['dir_mode'] : 0777, true); 
    4850    } 
    4951 
    50     if (!is_writable($dir) || (file_exists($options['file']) && !is_writable($options['file']))) 
     52    if (!is_writable($dir) || ($fileExists = file_exists($options['file']) && !is_writable($options['file']))) 
    5153    { 
    5254      throw new sfFileException(sprintf('Unable to open the log file "%s" for writing.', $options['file'])); 
     
    5456 
    5557    $this->fp = fopen($options['file'], 'a'); 
     58    if (!$fileExists) 
     59    { 
     60      chmod($options['file'], isset($options['file_mode']) ? $options['file_mode'] : 0666); 
     61    } 
    5662 
    5763    return parent::initialize($dispatcher, $options); 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting, and supporting several large Open-Source projects.