diff options
author | BlueRaja <BlueRaja.admin@gmail.com> | 2013-06-01 20:10:36 -0500 |
---|---|---|
committer | BlueRaja <BlueRaja.admin@gmail.com> | 2013-06-01 20:10:36 -0500 |
commit | 951330c9f83c8c8ee98f65fdccb5797e2e59d1f3 (patch) | |
tree | fc7b196ca0d91c1c71dcd945aa9667c7af0134fa /includes/HybridAuth/Logger.php | |
parent | e58a3b8b3702b22c903b02a9b4fa1020d6797459 (diff) | |
download | pathery-951330c9f83c8c8ee98f65fdccb5797e2e59d1f3.tar.xz |
A partial commit of the auth stuff, in case my upcoming changes break anything
Diffstat (limited to 'includes/HybridAuth/Logger.php')
-rw-r--r-- | includes/HybridAuth/Logger.php | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/includes/HybridAuth/Logger.php b/includes/HybridAuth/Logger.php new file mode 100644 index 0000000..224cebc --- /dev/null +++ b/includes/HybridAuth/Logger.php @@ -0,0 +1,68 @@ +<?php +/*! +* HybridAuth +* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth +* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html +*/ + +/** + * Debugging and Logging manager + */ +class Hybrid_Logger +{ + function __construct() + { + // if debug mode is set to true, then check for the writable log file + if ( Hybrid_Auth::$config["debug_mode"] ){ + if ( ! file_exists( Hybrid_Auth::$config["debug_file"] ) ){ + throw new Exception( "'debug_mode' is set to 'true', but the file " . Hybrid_Auth::$config['debug_file'] . " in 'debug_file' does not exit.", 1 ); + } + + if ( ! is_writable( Hybrid_Auth::$config["debug_file"] ) ){ + throw new Exception( "'debug_mode' is set to 'true', but the given log file path 'debug_file' is not a writable file.", 1 ); + } + } + } + + public static function debug( $message, $object = NULL ) + { + if( Hybrid_Auth::$config["debug_mode"] ){ + $datetime = new DateTime(); + $datetime = $datetime->format(DATE_ATOM); + + file_put_contents( + Hybrid_Auth::$config["debug_file"], + "DEBUG -- " . $_SERVER['REMOTE_ADDR'] . " -- " . $datetime . " -- " . $message . " -- " . print_r($object, true) . "\n", + FILE_APPEND + ); + } + } + + public static function info( $message ) + { + if( Hybrid_Auth::$config["debug_mode"] ){ + $datetime = new DateTime(); + $datetime = $datetime->format(DATE_ATOM); + + file_put_contents( + Hybrid_Auth::$config["debug_file"], + "INFO -- " . $_SERVER['REMOTE_ADDR'] . " -- " . $datetime . " -- " . $message . "\n", + FILE_APPEND + ); + } + } + + public static function error($message, $object = NULL) + { + if( Hybrid_Auth::$config["debug_mode"] ){ + $datetime = new DateTime(); + $datetime = $datetime->format(DATE_ATOM); + + file_put_contents( + Hybrid_Auth::$config["debug_file"], + "ERROR -- " . $_SERVER['REMOTE_ADDR'] . " -- " . $datetime . " -- " . $message . " -- " . print_r($object, true) . "\n", + FILE_APPEND + ); + } + } +} |