Example #1
1
File: monolog.php Project: yfix/yf
#!/usr/bin/php
<?php 
$config = ['require_services' => ['psr_log'], 'git_urls' => ['https://github.com/Seldaek/monolog.git' => 'monolog/'], 'autoload_config' => ['monolog/src/Monolog/' => 'Monolog'], 'example' => function () {
    $file = '/tmp/test_monolog.log';
    file_exists($file) && unlink($file);
    // create a log channel
    $log = new Monolog\Logger('name');
    $log->pushHandler(new Monolog\Handler\StreamHandler($file, Monolog\Logger::WARNING));
    // add records to the log
    $log->addWarning('Foo');
    $log->addError('Bar');
    echo file_get_contents($file);
}];
if ($return_config) {
    return $config;
}
require_once __DIR__ . '/_yf_autoloader.php';
new yf_autoloader($config);
 public function setUp()
 {
     $this->notifier = new NotifierMock(array('projectId' => 1, 'projectKey' => 'api_key'));
     $log = new \Monolog\Logger('billing');
     $log->pushHandler(new \Airbrake\MonologHandler($this->notifier));
     $log->addError('charge failed', array('client_id' => 123));
 }
 public function testErrorInMessage()
 {
     $client = new \Raven_Client();
     $handler = new \Raven_Breadcrumbs_MonologHandler($client);
     $logger = new Monolog\Logger('sentry');
     $logger->pushHandler($handler);
     $logger->addError($this->getSampleErrorMessage());
     $crumbs = $client->breadcrumbs->fetch();
     $this->assertEquals(count($crumbs), 1);
     $this->assertEquals($crumbs[0]['data']['type'], 'Exception');
     $this->assertEquals($crumbs[0]['data']['value'], 'An unhandled exception');
     $this->assertEquals($crumbs[0]['category'], 'sentry');
     $this->assertEquals($crumbs[0]['level'], 'error');
 }
Example #4
0
 /**
  * @param $data
  * @param string $code
  */
 public static function log($data, $code = 'debug')
 {
     $logfile = DATA . 'log/run.log';
     $log = new \Monolog\Logger('run');
     $log->pushHandler(new \Monolog\Handler\StreamHandler($logfile, \Monolog\Logger::WARNING));
     if ($code == 'info') {
         $log->addInfo($data);
     } elseif ($code == 'warn') {
         $log->addWarning($data);
     } elseif ($code == 'error') {
         $log->addError($data);
     } else {
         $log->addDebug($data);
     }
 }
Example #5
0
<?php

require_once __DIR__ . '/../autoload.php';
use Nrk\Fluent\Monolog\FluentHandler;
// Start fluentd on the local host using the sample configuration file
// that can be generated by calling fluentd with the -s option.
$log = new Monolog\Logger('debug.monolog');
$log->pushHandler(new FluentHandler('http://127.0.0.1'));
$log->pushHandler(new FluentHandler('tcp://127.0.0.1'));
$log->addError("OH NOES!!11!1!");
Example #6
0
        <?php 
require 'vendor/autoload.php';
use Acme\Hello;
$log = new Monolog\Logger('logger');
$log->pushHandler(new Monolog\Handler\StreamHandler('app.log', Monolog\Logger::WARNING));
$log->addWarning("cuidado esto es un warning");
$saludo = new Hello();
if ($saludo) {
    echo $saludo->getMessage();
} else {
    $log->addError("algun error ha ocurrido");
}
Example #7
0
<?php

require __DIR__ . '/lib/autoload.php';
# Your Wordpress website is at: http://wp-website.com
$endpoint = "http://beta.xudoanchuahienlinh.com/xmlrpc.php";
# The Monolog logger instance
$wpLog = new Monolog\Logger('wp-xmlrpc');
# Create client instance
$wpClient = new \HieuLe\WordpressXmlrpcClient\WordpressClient();
# Log error
$wpClient->onError(function ($error, $event) use($wpLog) {
    var_dump($error);
    echo "<br><br>";
    var_dump($event);
    $wpLog->addError($error, $event);
});
# Set the credentials for the next requests
$wpClient->setCredentials($endpoint, 'admin', '12345678@X');
$profile = $wpClient->getProfile(array('user_id', 'username', 'email', 'roles'));
var_dump($profile);
//foreach ($resp as $value) {
echo "<br><br>";
echo $profile["user_id"];
echo "<br><br>";
echo "Username: "******"username"];
echo "<br><br>";
echo "Display name: " . $profile["email"];
echo "<br><br>";
//    };