예제 #1
0
 /**
  * @depends test_format
  */
 function test_handler()
 {
     // Test logging using a closure
     Analog::handler(function ($msg) {
         AnalogTest::$log .= vsprintf(Analog::$format, $msg);
     });
     Analog::log('Testing');
     $this->assertStringMatchesFormat("localhost, %d-%d-%d %d:%d:%d, 3, Testing\n", self::$log);
 }
예제 #2
0
 /**
  * @depends test_format
  */
 function test_handler()
 {
     // Test logging using a closure
     Analog::handler(function ($msg) {
         AnalogTest::$log .= vsprintf(Analog::$format, $msg);
     });
     Analog::log('Testing');
     $this->assertEquals(sprintf("%s, %s, %d, %s\n", 'localhost', gmdate('Y-m-d H:i:s'), 3, 'Testing'), self::$log);
 }
예제 #3
0
 public function __construct()
 {
     if (!file_exists("./log_files")) {
         mkdir('./log_files');
     }
     $this->log_file = "./log_files/Log.txt";
     if (file_exists($this->log_file)) {
         if (filesize($this->log_file) >= MD_LOG_FILE_SIZE) {
             unlink($this->log_file);
         }
     }
     Analog::handler(Analog\Handler\File::init($this->log_file));
 }
예제 #4
0
 public function __construct()
 {
     $this->path = MD_ROOT . "/log_files";
     if (!file_exists($this->path)) {
         mkdir($this->path);
     }
     $this->log_file = $this->path . "/ErrorLog.txt";
     if (file_exists($this->log_file)) {
         if (filesize($this->log_file) >= MD_LOG_FILE_SIZE) {
             unlink($this->log_file);
         }
     }
     Analog::handler(Analog\Handler\File::init($this->log_file));
 }
예제 #5
0
 public function __construct($message = null, $code = 0)
 {
     if (!file_exists("./log_files")) {
         mkdir('./log_files');
     }
     $this->log_file = './log_files/Log.txt';
     if (!$message) {
         throw new $this('Unknown ' . get_class($this));
     }
     Analog::handler(Analog\Handler\File::init($this->log_file));
     parent::__construct($message, $code);
     Analog::log($this->__toString(), Analog::ERROR);
     $handleFilesFolder = new HandleFilesFolder();
     $handleFilesFolder->handle();
     if (file_exists("FTP_SEMAMPHORE.smph")) {
         unlink("FTP_SEMAMPHORE.smph");
     }
 }
 public function __construct($message = "Unknown error", $code = 0)
 {
     if (!file_exists(MD_LOG_FILE_DIR)) {
         mkdir(MD_LOG_FILE_DIR);
     }
     $this->log_file = MD_LOG_FILE_DIR . '/Log.txt';
     if (!$message) {
         throw new $this('Unknown ' . get_class($this));
     }
     Analog::handler(Analog\Handler\File::init($this->log_file));
     if (gettype($message) !== "string") {
         $message = "Unknown error";
     }
     parent::__construct($message, 10);
     Analog::log($this->__toString(), Analog::ERROR);
     $handleFilesFolder = new HandleFilesFolder();
     $handleFilesFolder->handle();
     if (file_exists(MD_ROOT . "/FTP_SEMAMPHORE.smph")) {
         unlink(MD_ROOT . "/FTP_SEMAMPHORE.smph");
     }
 }
예제 #7
0
<?php

require '../lib/Analog.php';
Analog::handler(Analog\Handler\Mongo::init('localhost:27017', 'testing', 'log'));
Analog::log('Error message');
Analog::log('Debug info', Analog::DEBUG);
$m = new Mongo('localhost:27017');
$cur = $m->testing->log->find();
foreach ($cur as $doc) {
    print_r($doc);
}
$m->testing->log->remove();
예제 #8
0
<?php

require '../lib/Analog.php';
$log = '';
Analog::handler(Analog\Handler\Post::init('http://localhost:8080/'));
Analog::log('foo');
Analog::log('bar');
echo $log;
예제 #9
0
<?php

require '../lib/Analog.php';
$log = '';
Analog::handler(Analog\Handler\Threshold::init(Analog\Handler\Variable::init($log), Analog::ERROR));
// these will be ignored
Analog::log('Debugging...', Analog::DEBUG);
Analog::log('Minor warning...', Analog::WARNING);
echo "Log is still empty:\n" . $log . "\n";
// but these will be logged
Analog::log('An error...', Analog::ERROR);
Analog::log('Oh noes!', Analog::URGENT);
echo "Log now has everything:\n" . $log;
예제 #10
0
<?php

require '../lib/Analog.php';
Analog::handler(Analog\Handler\Ignore::init());
Analog::log('Hellooooooo');
예제 #11
0
<?php

require '../lib/Analog.php';
Analog::handler(Analog\Handler\Stderr::init());
Analog::log('Output to php://stderr');
예제 #12
0
<?php

require '../lib/Analog.php';
Analog::log('foo');
Analog::log('bar');
echo file_get_contents(Analog::handler());
unlink(Analog::handler());
예제 #13
0
<?php

require '../lib/Analog.php';
Analog::handler(Analog\Handler\ChromeLogger::init());
// debug-level message
Analog::debug($_SERVER);
// an info message
Analog::info('An error message');
// a warning message
Analog::warning('Turn back before it\'s too late');
// an error with no file/line #'s
Analog::log('Another error message');
예제 #14
0
<?php

// 1. Install the GELF classes from https://github.com/Graylog2/gelf-php
require 'GELFMessage.php';
require 'GELFMessagePublisher.php';
require '../lib/Analog.php';
Analog::handler(Analog\Handler\GELF::init('localhost'));
Analog::log('Error message');
Analog::log(array('Debug info', __FILE__, __LINE__), Analog::DEBUG);
예제 #15
0
<?php

require '../lib/Analog.php';
Analog::handler(Analog\Handler\Buffer::init(Analog\Handler\Mail::init('*****@*****.**', 'Log messages', '*****@*****.**')));
// will all be sent as one email instead of three
Analog::log('Message one');
Analog::log('Message two');
Analog::log('Message three');
예제 #16
0
<?php

require '../lib/Analog.php';
$errors = "Errors:\n";
$warnings = "Warnings:\n";
$debug = "Debug:\n";
Analog::handler(Analog\Handler\Multi::init(array(Analog::ERROR => Analog\Handler\Variable::init($errors), Analog::WARNING => Analog\Handler\Variable::init($warnings), Analog::DEBUG => Analog\Handler\Variable::init($debug))));
Analog::log('First error');
Analog::log('Emergency!', Analog::URGENT);
Analog::log('A warning...', Analog::WARNING);
Analog::log('Some info', Analog::INFO);
Analog::log('Debugging output', Analog::DEBUG);
echo $errors;
echo "-----\n";
echo $warnings;
echo "-----\n";
echo $debug;
예제 #17
0
<?php

require '../lib/Analog.php';
Analog::handler(Analog\Handler\Null::init());
Analog::log('Hellooooooo');
예제 #18
0
<?php

require '../lib/Analog.php';
$log = '';
Analog::handler(Analog\Handler\LevelBuffer::init(Analog\Handler\Variable::init($log), Analog::CRITICAL));
// none of these will trigger sending the log
Analog::log('Debugging...', Analog::DEBUG);
Analog::log('Minor warning...', Analog::WARNING);
Analog::log('An error...', Analog::ERROR);
echo "Log is still empty:\n" . $log . "\n";
// but this will, and will include all the others in the log
Analog::log('Oh noes!', Analog::URGENT);
echo "Log now has everything:\n" . $log;
예제 #19
0
<?php

// 1. Install the Amon PHP lib from http://amon.cx/guide/clients/php/
require 'amon.php';
require '../lib/Analog.php';
Analog::handler(Analog\Handler\Amon::init('http://127.0.0.1', 2464));
Analog::log('Error message');
Analog::log('Debug info', Analog::DEBUG);
예제 #20
0
<?php

require '../lib/Analog.php';
$log_file = 'log.txt';
Analog::handler(Analog\Handler\File::init($log_file));
Analog::log('foo');
Analog::log('bar');
echo file_get_contents($log_file);
unlink($log_file);
예제 #21
0
<?php

require '../lib/Analog.php';
Analog::handler(Analog\Handler\FirePHP::init());
// debug-level message
Analog::log(array('A debug message', __FILE__, __LINE__), Analog::DEBUG);
// an info message
Analog::log(array('An error message', __FILE__, __LINE__), Analog::INFO);
// an error with no file/line #'s
Analog::log('Another error message');
예제 #22
0
<?php

require '../lib/Analog.php';
$log = '';
Analog::handler(Analog\Handler\Variable::init($log));
Analog::log('foo');
Analog::log('bar');
echo $log;
예제 #23
0
<?php

require '../lib/Analog.php';
Analog::handler(Analog\Handler\Syslog::init('analog', 'user'));
Analog::log('Error message', Analog::WARNING);