holabs/logger

User logging for Nette framework

v1.0.2 2018-01-11 12:17 UTC

README

Easy logging class for maps user's/system activity or debugging.

Logging:

  • action (Defined by developer)
  • parameters (Defined by developer)
  • REMOTE_ADDRESS (auto)
  • User-Agent (auto)
  • User ID (auto if logged in)

Installation

Requirements:

Optional:

composer require holabs/logger
composer require nette/database	# optional
composer require tracy/tracy	# optional

Configuration

extensions:
	holabs.logger: Holabs\Logger\Bridges\Nette\LoggerExtension
	
tracy:
	bar:
		- Holabs\Logger\Bridges\Tracy\LoggerPanel

# Optional if you want to persist(or change for your own storage) your logs over nette database
services:
	# Holabs\Logger\Storages\IStorage
	holabs.logger.storage: Holabs\Logger\Storages\NetteDatabaseStorage('tablename')

You can choose your storage or use predefined.

Using

Your BasePresenter or some component now can looks like this:

<?php

namespace App\Presenters;

use Holabs\Logger\TLogger;
use Nette\Application\UI\Presenter;


abstract class BasePresenter extends Presenter {

	// Inject property $logger and create LOG method
	use TLogger;

	public function startup() {
		parent::startup();

		$this->log('test', ['testing']);
	}

}