Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
6690ff5c
Commit
6690ff5c
authored
Jan 21, 2014
by
dazz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made event callables injectable with pimple. refs #870
parent
7cd21dc2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
18 deletions
+30
-18
src/Silex/Provider/MonologServiceProvider.php
src/Silex/Provider/MonologServiceProvider.php
+30
-18
No files found.
src/Silex/Provider/MonologServiceProvider.php
View file @
6690ff5c
...
...
@@ -64,35 +64,47 @@ class MonologServiceProvider implements ServiceProviderInterface
return
Logger
::
DEBUG
;
};
$app
[
'monolog.boot.before'
]
=
$app
->
protect
(
function
(
Request
$request
)
use
(
$app
)
{
$app
[
'monolog'
]
->
addInfo
(
'> '
.
$request
->
getMethod
()
.
' '
.
$request
->
getRequestUri
());
}
);
$app
[
'monolog.boot.error'
]
=
$app
->
protect
(
function
(
\Exception
$e
)
use
(
$app
)
{
$message
=
sprintf
(
'%s: %s (uncaught exception) at %s line %s'
,
get_class
(
$e
),
$e
->
getMessage
(),
$e
->
getFile
(),
$e
->
getLine
());
if
(
$e
instanceof
HttpExceptionInterface
&&
$e
->
getStatusCode
()
<
500
)
{
$app
[
'monolog'
]
->
addError
(
$message
,
array
(
'exception'
=>
$e
));
}
else
{
$app
[
'monolog'
]
->
addCritical
(
$message
,
array
(
'exception'
=>
$e
));
}
}
);
$app
[
'monolog.boot.after'
]
=
$app
->
protect
(
function
(
Request
$request
,
Response
$response
)
use
(
$app
)
{
if
(
$response
instanceof
RedirectResponse
)
{
$app
[
'monolog'
]
->
addInfo
(
'< '
.
$response
->
getStatusCode
()
.
' '
.
$response
->
getTargetUrl
());
}
else
{
$app
[
'monolog'
]
->
addInfo
(
'< '
.
$response
->
getStatusCode
());
}
}
);
$app
[
'monolog.name'
]
=
'myapp'
;
}
public
function
boot
(
Application
$app
)
{
$app
->
before
(
function
(
Request
$request
)
use
(
$app
)
{
$app
[
'monolog'
]
->
addInfo
(
'> '
.
$request
->
getMethod
()
.
' '
.
$request
->
getRequestUri
());
});
$app
->
before
(
$app
[
'monolog.boot.before'
]);
/*
* Priority -4 is used to come after those from SecurityServiceProvider (0)
* but before the error handlers added with Silex\Application::error (defaults to -8)
*/
$app
->
error
(
function
(
\Exception
$e
)
use
(
$app
)
{
$message
=
sprintf
(
'%s: %s (uncaught exception) at %s line %s'
,
get_class
(
$e
),
$e
->
getMessage
(),
$e
->
getFile
(),
$e
->
getLine
());
if
(
$e
instanceof
HttpExceptionInterface
&&
$e
->
getStatusCode
()
<
500
)
{
$app
[
'monolog'
]
->
addError
(
$message
,
array
(
'exception'
=>
$e
));
}
else
{
$app
[
'monolog'
]
->
addCritical
(
$message
,
array
(
'exception'
=>
$e
));
}
},
-
4
);
$app
->
error
(
$app
[
'monolog.boot.error'
],
-
4
);
$app
->
after
(
function
(
Request
$request
,
Response
$response
)
use
(
$app
)
{
if
(
$response
instanceof
RedirectResponse
)
{
$app
[
'monolog'
]
->
addInfo
(
'< '
.
$response
->
getStatusCode
()
.
' '
.
$response
->
getTargetUrl
());
}
else
{
$app
[
'monolog'
]
->
addInfo
(
'< '
.
$response
->
getStatusCode
());
}
});
$app
->
after
(
$app
[
'monolog.boot.after'
]);
}
public
static
function
translateLevel
(
$name
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment