Skip to content

Commit 734b12a

Browse files
committed
Add LICENSE & README
1 parent 9978e08 commit 734b12a

File tree

3 files changed

+91
-1
lines changed

3 files changed

+91
-1
lines changed

LICENSE

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2012 Nelmio
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is furnished
8+
to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

README.md

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
NelmioJsLoggerBundle
2+
====================
3+
4+
The **NelmioJsLoggerBundle** bundle allows you to log errors happening in the frontend.
5+
6+
## Installation ##
7+
8+
Add this bundle to your `composer.json` file:
9+
10+
{
11+
"require": {
12+
"nelmio/js-logger-bundle": "dev-master"
13+
}
14+
}
15+
16+
Register the bundle in `app/AppKernel.php`:
17+
18+
// app/AppKernel.php
19+
public function registerBundles()
20+
{
21+
return array(
22+
// ...
23+
new Nelmio\JsLoggerBundle\NelmioJsLoggerBundle(),
24+
);
25+
}
26+
27+
Import the bundle's routing definition in `app/config/routing.yml`:
28+
29+
# app/config/routing.yml
30+
NelmioJsLoggerBundle:
31+
resource: "@NelmioJsLoggerBundle/Resources/config/routing.xml"
32+
prefix: /nelmio-js-logger
33+
34+
## Automated Error Logging ##
35+
36+
The bundle exposes two twig functions that you should put in your site template somewhere.
37+
38+
To enable automatic logging of javascript errors, use `nelmio_js_error_logger()`:
39+
40+
{{ nelmio_js_error_logger() }}
41+
42+
You can optionally change the level (default is ERROR) and remove the surrounding `<script>..</script>` tags:
43+
44+
{{ nelmio_js_error_logger('WARNING', false) }}
45+
46+
## Manual Logging from JavaScript ##
47+
48+
To expose the `log()` function to your JS code, use `nelmio_js_logger()`:
49+
50+
{{ nelmio_js_logger() }}
51+
52+
You can also change the function name if `log` is too generic for you:
53+
54+
{{ nelmio_js_logger('my_log_function') }}
55+
56+
The function signature is as such: `log(level, message, context)`. The level and
57+
message are mandatory. The context is a data object that can contain any additional
58+
details you want to store.
59+
60+
## Configuration ##
61+
62+
You can restrict the logging levels accessible from javascript. The point
63+
is that if some of your logging levels email you or notify you in some way,
64+
you probably do not want to allow anyone to send requests and wake you up
65+
at 2AM.
66+
67+
Here is the default configuration that exposes all levels:
68+
69+
# app/config/config.yml
70+
nelmio_js_logger:
71+
allowed_levels: ['DEBUG', 'INFO', 'NOTICE', 'WARNING', 'ERROR', 'CRITICAL', 'ALERT', 'EMERGENCY']

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
}
1616
],
1717
"require": {
18-
"symfony/framework-bundle": ">=2.1,<2.2-dev"
18+
"symfony/framework-bundle": ">=2.0,<2.2-dev"
1919
},
2020
"autoload": {
2121
"psr-0": { "Nelmio\\JsLoggerBundle": "" }

0 commit comments

Comments
 (0)