Created
November 12, 2009 05:37
-
-
Save sminnee/232631 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Simple implementation of the SS_Log class that came in 2.4, for compatability with SilverStripe 2.3. | |
| */ | |
| class SS_Log { | |
| protected static $writer; | |
| protected static $priority_names = array( | |
| 3 => 'ERR', | |
| 4 => 'WARN', | |
| 5 => 'NOTICE', | |
| GUARDIANLOGPAGEVIEW => 'PAGEVIEW', | |
| ); | |
| static function add_writer($writer) { | |
| self::$writer = $writer; | |
| } | |
| static function log($message, $priority) { | |
| if(!self::$writer) return; | |
| // Convert string priorities from 2.3 into numeric ones, used by the writer | |
| if(is_string($priority)) { | |
| $errNums = array( | |
| 'Error' => 3, | |
| 'Warning' => 4, | |
| 'Notice' => 5, | |
| ); | |
| $priority = $errNums[$priority]; | |
| } | |
| return self::$writer->_write(array( | |
| 'priorityName' => self::$priority_names[$priority], | |
| 'message' => $message, | |
| )); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment