Example #1
0
 /**
  * Test custom format
  */
 function testCustomFormat()
 {
     Logger::log('Hello', array('format' => "[%s] [%s] %s", 'inputs' => array('LOG', 'LoggerTest.php')));
     $this->expectOutputString("[LOG] [LoggerTest.php] Hello\n");
 }
Example #2
0
<?php

/**
 * Logging examples
 */
require dirname(__FILE__) . "/../lib/FusePump/Cli/Logger.php";
use FusePump\Cli\Logger;
Logger::log('Hello!');
// => [2012-11-15 18:12:34] [LOG] [logging.php] Hello!
Logger::log('This is red!', array('colour' => 'red'));
// => [2012-11-15 18:12:34] [LOG] [logging.php] This is red!
Logger::log('This is green!', array('colour' => 'green'));
// => [2012-11-15 18:12:34] [LOG] [logging.php] This is green!
Logger::log('Custom formatting options!', array('format' => '[%s] %s', 'inputs' => array('custom_log')));
// => [Custom log] Custom formatting options!
Logger::warn('This is a warning');
// => [2012-11-15 18:12:34] [WARN] [logging.php] This is a warning
Logger::error('This is an error');
// => [2012-11-15 18:12:34] [ERROR] [logging.php] This is an error
Logger::out('Plain output');
// => Plain output
Logger::out('Plain output with colour!', 'red');
// => Plain output with colour!
// Log to a file
Logger::log('Log to a file', array('output' => 'output.log'));
// Disable colour output
Logger::$errorColour = '';
Logger::error('Log an error to a file', array('output' => 'output.err'));
Logger::out('Log some text to a file', false, 'output.log');
Example #3
0
<?php

/**
 * Output all the colours available
 */
require dirname(__FILE__) . '/../lib/FusePump/Cli/Logger.php';
use FusePump\Cli\Logger;
use FusePump\Cli\Colours;
$colours = Colours::getForegroundColours();
foreach ($colours as $colour) {
    Logger::log($colour, array('colour' => $colour, 'format' => '%s', 'inputs' => array()));
}