Skip to content

Commit

Permalink
Better logger file handling
Browse files Browse the repository at this point in the history
  • Loading branch information
tomnomnom committed Mar 2, 2012
1 parent d1081cb commit 64b4a8f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions Library/Factory/Logger.php
Expand Up @@ -8,8 +8,16 @@ public function make(){
case 'file':
// Make relative files relative to the config file
$file = $this->settings->log['file'];
if (!is_writable($file)){
throw new \InvalidArgumentException("[{$file}] is not writable");
if (file_exists($file)){
if (!is_writable($file)){
throw new \InvalidArgumentException("[{$file}] is not writable");
}
} else {
if (is_writeable(dirname($file))){
touch($file);
} else {
throw new \InvalidArgumentException("[".dirname($file)."] is not writable; could not create log file");
}
}
if (in_array(substr($file, 0, 2), array('./', '..'))){
$file = __DIR__.'/../../'.$file;
Expand Down
4 changes: 2 additions & 2 deletions config.example.ini
Expand Up @@ -5,13 +5,13 @@ token = ""
token_secret = ""

[log]
; Possible values are "file" and "null"
; Possible values are "file", "screen" and "null"
type = "file"

; Possible values are "EMERGE", "ALERT", "CRIT", "ERR", "WARN", "NOTICE", "INFO" and "DEBUG"
level = "INFO"

file = "/var/log/tvyv.log"
file = "/tmp/vimeo-uploader.log"

[debug]
; Set to "true" to not actually upload videos
Expand Down

0 comments on commit 64b4a8f

Please sign in to comment.