Comments (11)
This look interesting.
@ccampbell do you have a place where you describe the way the headers should be formatted to send a log message to the extension ?
from monolog.
I don't have it documented anywhere, but I can give a brief overview.
The data to be logged starts out with an array that looks like this:
Each log is an array entry in rows that looks like this:
$data = array(
0 => 'log label', // if applicable
1 => 'log message', // or array / array representation of object
2 => 'path/to/file.php : line_number',
3 => '' // log type ('log', 'error', 'warn', etc)
);
Then you would convert this data to a header by doing something like this:
header('X-ChromePhp-Data: ' . base64_encode(utf8_encode(json_encode($data))));
Check out the source at: https://github.com/ccampbell/chromephp/blob/master/ChromePhp.php to see exactly what is going on.
from monolog.
OK, so we need to create a big array and set it as a single header.
do you have an idea about how we could handle the context array provided with Monolog messages ? for all messages, we are able to pass a string message and an array of context (for instance, we can use it to log the SQL query and the array of bound parameters). For FirePHP, we currently send array('message' => $message, 'context' => $context)
as logged data but maybe something better can be done for ChromePHP ?
from monolog.
@ccampbell btw, does the extension change the user agent or add a custom request header that we could use to send the ChromePHP header only for browsers that have ChromePHP (thus avoiding issues with IE that has a lower limit for the header size) ?
from monolog.
Right now I do not add any additional headers client side, but I will add it if it will be useful to you. You could also do a UA check to make sure it is Chrome before setting the header maybe?
from monolog.
well, we could detect Chrome, but it would even be better if we know that it is Chrome with ChromePHP.
Btw, I saw a weird thing when testing it. For the error level message, a stack trace inside the extension was added to the console message, whereas other levels were clean. Is it a bug in the extension ? You can reproduce it by accessing monolog/tests/Monolog/Functional/Handler/FirePHPHandlerTest.php
when using the code in my PR linked above.
from monolog.
I noticed this too, I believe this is something that Chrome added to the console in Chrome 17. If you do any console.error() regardless of if it is a javascript error it shows a js stack trace.
You can reproduce by simply opening up the console:
So I'm not sure if there is any way around it, but I will see.
from monolog.
@stof the problem in IE was only caused by having too many headers I think, not very large ones like in this case, but that said there might be a limit there that I didn't hit. Anyway having a custom header of some sort when ChromePHP is enabled would be quite nice.
from monolog.
@Seldaek I updated the PR to detect Chrome at least.
from monolog.
Is there a documentation entry for what exact chrome extension the ChromePHPHandler was built? I am lucky to found this issue, because there are multiple extensions claiming to be (a) chrome php logger.
from monolog.
The readme has a link to the extension website
from monolog.
Related Issues (20)
- PHPDoc out of sync on StreamHandler HOT 1
- Is it possibile to log to the stream that is completely outside of the application environment? HOT 5
- Issue with Logging to stdout in Laravel 10.21 using Monolog v3 EXCEPTION#Cannot log request: fwrite(): Write of 378 bytes failed with errno=32 Broken pipe HOT 32
- The file does not close after writing HOT 5
- How do I use includeStacktraces? HOT 1
- Support more flexible normalizer HOT 2
- cannot access private method HOT 7
- Add support for Elasticsearch with Bulk API and data stream HOT 1
- Could a new release be considered to remove the 0.7MB logo from the package ? HOT 1
- Uncaught Error: Class "Monolog\Logger" not found HOT 7
- User definable duplication for DeduplicationHandler
- Encounter problem in format function HOT 3
- DatetimeImmutable HOT 1
- [Discussion] Reset FingersCrossedHandler on stateful runtimes HOT 8
- Extending Processors - private properties HOT 1
- Incorrect logs are written in Monolog files intermittently HOT 1
- Truncated JsonFormatter logs at 8191 characters HOT 5
- Log Message is truncated HOT 1
- Log level not compliant with rfc5424 HOT 2
- DeduplicationHandler in a read only container HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from monolog.