IntrospectionProcessor and LineFormatter invalid JSON #110

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

Comments

Projects
None yet
3 participants
@jrjohnson

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

This comment has been minimized.

Show comment Hide comment
@stof

stof Sep 5, 2012

Contributor

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

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

This comment has been minimized.

Show comment Hide comment
@stof

stof Sep 5, 2012

Contributor

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

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

This comment has been minimized.

Show comment Hide comment
@jrjohnson

jrjohnson Sep 5, 2012

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.

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

This comment has been minimized.

Show comment Hide comment
@stof

stof Sep 5, 2012

Contributor

@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

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

This comment has been minimized.

Show comment Hide comment
@jrjohnson

jrjohnson Sep 5, 2012

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"}

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 in a929570 Sep 5, 2012

@Seldaek

This comment has been minimized.

Show comment Hide comment
@Seldaek

Seldaek Sep 5, 2012

Owner

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.

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