Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IntrospectionProcessor and LineFormatter invalid JSON #110

Closed
jrjohnson opened this issue Sep 5, 2012 · 6 comments
Closed

IntrospectionProcessor and LineFormatter invalid JSON #110

jrjohnson opened this issue Sep 5, 2012 · 6 comments

Comments

@jrjohnson
Copy link

The introspection processor adds the class name to the extra paramters - if this name is namespaced (has a ) then the json that results from LineFormatter is invalid and cannot be re-assembled using json_decode.

eg:

{
    "file": "/src/Name/NameClass.php",
    "class": "Name\NameClass"
}

Its possible this is addressed in PHP 5.4 using the JSON_UNESCAPED_SLASHES - but it should be backwards compatible as well. I assume this would be an issue for any unescape slashes added by any of the processors.

@stof
Copy link
Contributor

stof commented Sep 5, 2012

Please fix your markdown to use code-blocks when necessary, to avoid the escaping of the content. The link to the markdown help is available both in the footer of the github website and near the comment form

@stof
Copy link
Contributor

stof commented Sep 5, 2012

and btw, in which place does it create invalid json ? LineFormatter is not meant to produce json (there is a JsonFormatter for that)

@jrjohnson
Copy link
Author

LineFormater produces JSON in convertToString which gets called in format for every value in extras. It looks to me like the written output of extras is intended to be JSON.

@stof
Copy link
Contributor

stof commented Sep 5, 2012

@jrjohnson it uses json_encode in some cases (note that it is not all cases), because it is a readable way to write arrays on 1 line. But it was never intended to write json. If you want to log as JSON, use the dedicated formatter

@jrjohnson
Copy link
Author

OK so the extras string is just a comma separated list of values inclosed in {} that is very nearly correct JSON?

{"line":432,"function":"handleException","ip":"206.211.148.90","http_method":"GET","referrer":"NULL"}

@Seldaek Seldaek closed this as completed in a929570 Sep 5, 2012
@Seldaek
Copy link
Owner

Seldaek commented Sep 5, 2012

Indeed in 5.4 it will return proper json, but in 5.3 it didn't because of the slightly too greedy stripslashes. Fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants