You can download the github version. How to install
Or using composer : composer require zaeder/js-logger-bundle
1 - Add bundle to app/AppKernel.php
How to configure<?php
2 - Add your user entity class to app/config/config.yml
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
[...],
new Zaeder\Link4mailingBundle\ZaederJsLoggerBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'), true)) {
[...]
}
return $bundles;
}
[...]
}monolog:
handlers:
[...]
js_logger:
type: stream
path: "%kernel.logs_dir%/js_%kernel.environment%.log"
level: debug
channels: [jsLogger]
zaeder_js_logger:
allowed_levels: ['DEBUG', 'INFO', 'NOTICE', 'WARNING', 'ERROR', 'CRITICAL', 'ALERT', 'EMERGENCY']
monolog_channel: jsLogger
There is two modes : manual and auto. Define mode
It's defined by a twig extension function which you have to defined before your scripts.
{{ zaeder_js_logger() }}
: Manual mode
{{ zaeder_js_auto_logger() }}
: Automatic mode
In this mode, the developer have to use Manual modejsLogger(level, message, contextData)
to log his message.
Function's arguments :
level
: Must be in ['DEBUG', 'INFO', 'NOTICE', 'WARNING', 'ERROR', 'CRITICAL', 'ALERT', 'EMERGENCY'] and defined in config file (mandatory)
message
: Message to log (mandatory)
contextData
: Other information like the stack, the file, the user agent, … (optional)
In this mode, the javascripts errors will be logged automatically. The methods Automatic modeconsole.debug
, console.info
, console.warn
, console.error
either if the levels defined in config file allowed it.