Created
November 11, 2012 02:10
-
-
Save ScreamingDev/4053375 to your computer and use it in GitHub Desktop.
PHP CLI Class for logging warning quiet and verbose
This file contains 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
namespace CLI; | |
class Log | |
{ | |
protected $_verbose = false; | |
protected $_debug = false; | |
protected $_quiet = false; | |
protected function _log ( $message, $lineFeed = true ) | |
{ | |
if ( $lineFeed ) | |
{ | |
print PHP_EOL; | |
} | |
if ( $this->_quiet ) | |
{ | |
return; | |
} | |
print $message; | |
flush(); | |
} | |
protected function _verbose ( $message, $lineFeed = true) | |
{ | |
if ( $this->_verbose ) | |
{ | |
$this->_log($message, $lineFeed); | |
} | |
else | |
{ | |
$this->_log('.', false); | |
} | |
} | |
protected function _debug ( $message, $lineFeed = true) | |
{ | |
if ( $this->_debug ) | |
{ | |
$this->_log($message, $lineFeed); | |
} | |
else | |
{ | |
$this->_log('.', false); | |
} | |
} | |
protected function _warning ( $message, $lineFeed = true ) | |
{ | |
if ( !$this->_quiet ) | |
{ | |
$this->_log($message, $lineFeed); | |
} | |
} | |
protected function _error ( $message, $lineFeed = true ) | |
{ | |
$this->_log($message, $lineFeed); | |
} | |
protected function _exit ($flag) | |
{ | |
print PHP_EOL; | |
return exit( $flag ); | |
} | |
} |
This file contains 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment