Skip to content

Instantly share code, notes, and snippets.

@ScreamingDev
Created November 11, 2012 02:10
Show Gist options
  • Save ScreamingDev/4053375 to your computer and use it in GitHub Desktop.
Save ScreamingDev/4053375 to your computer and use it in GitHub Desktop.
PHP CLI Class for logging warning quiet and verbose
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 );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment