Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
RealTime Monitoring "node" library for Nette Framework
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
VrtakCZ/Diagnostics
README.md

README.md

RealTime Monitoring "node" library for Nette Framework

Copyright (c) 2011 Patrik Votoček (http://patrik.votocek.cz)

Log errors, warning, debug etc or access logs.

Requirements

Usage

<?php
use Nette\Diagnostics\Debugger;

/**
 * @param string monitoring server host or IP
 * @param string monitoring server log listener port
 * @param string application name
 * @param string application (for better detect - dev, pub, lab instance) - optional
 */
$server = new VrtakCZ\Diagnostics\LogServer("localhost", 5679, "My Application name", "Application server IP");

/**
 * @param LogServer log server instance
 * @param Logger another logger (for cascade log) - optional
 */
Debugger::$logger = new VrtakCZ\Diagnostics\Logger($server, Debugger::$logger); // Debugger::$logger - use default logger too (network problems etc)

$context->application->onShutdown[] = function() use($server, $context) {
    /**
     * AccessLogger::create(...)
     * @param LogServer log server instance
     * 
     * AccessLogger->log(...)
     * @param Nette\Http\Request nette http request object instance
     */
    VrtakCZ\Diagnostics\AccessLogger::create($server)->log($context->httpRequest);
};

Example

<?php
use Nette\Diagnostics\Debugger;

require_once __DIR__ . "/nette.min.php";
require_once __DIR__ . "/../VrtakCZ/Diagnostics/LogServer.php";
require_once __DIR__ . "/../VrtakCZ/Diagnostics/Logger.php";
require_once __DIR__ . "/../VrtakCZ/Diagnostics/AccessLogger.php";

Debugger::enable(Debugger::DEVELOPMENT);

$reqFactory = new Nette\Http\RequestFactory;
$req = $reqFactory->createHttpRequest();

$server = new VrtakCZ\Diagnostics\LogServer("localhost", 5679, "Test");

Debugger::$logger = new VrtakCZ\Diagnostics\Logger($server);
if ($req->getQuery('error')) {
    // Log errors etc
    Debugger::log(new \Exception("Log Exception"), Debugger::ERROR);
    Debugger::log("This is normal info message");
    Debugger::log("Critical message", Debugger::CRITICAL);
    Debugger::log("Error", Debugger::ERROR);
    Debugger::log("An error occurred that did not occur", Debugger::WARNING);
    Debugger::log("I need a beer!", Debugger::DEBUG);
}

// Log access
VrtakCZ\Diagnostics\AccessLogger::create($server)->log($req);

Screenshot

Something went wrong with that request. Please try again.