fpillet / NSLogger

A modern, flexible logging tool
Other
5k stars 573 forks source link

URL encoded query parameters are a mess when displayed in NSLogger app #277

Closed NeverwinterMoon closed 5 years ago

NeverwinterMoon commented 5 years ago

Something like this: https://foo.com/path?country=EE&returnUrl=https%253A%252F%252Fbar.com%252F%253Fcountry%253DEE is displayed exactly like I posted above in Xcode or AppCode logs, but in NSLogger app it looks like:


[203     ] 12:52:03.933 | Debug | Main thread | About to load WebView with URL [https://foo.com/path?country=EE&returnUrl=https
0X0P+0
0.000000
0.000000bar.com0.000000
0.000000country
0EE]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ```
fpillet commented 5 years ago

Oh fun :) wasn't aware of this bug! Thanks for reporting 👍 will fix ASAP

fpillet commented 5 years ago

@NeverwinterMoon Just occurred to me that this may not be a NSLogger issue. How are you logging your request ? If you are logging from ObjC, make sure you do NOT pass directly your request string because the % will be interpreted as formatting characters.

In Obj-C you want to log "%@", requestString In Swift you want to log "(requestString)"

If already doing that, can you show the code line(s) logging the URL ?

NeverwinterMoon commented 5 years ago

@fpillet Oh, you might be onto something. I am actually using NSLogger through XCGLogger and have have been doing that for so long, I've forgotten I am using XCGlogger at all...

NSLogger is added as a destination to XCGlogger this way:

LogMessageF_va(
          logDetails.fileName,
          Int32(logDetails.lineNumber),
          logDetails.functionName,
          domain,
          Int32(convertLogLevel(logDetails.level)),
          logDetails.message,
          getVaList([])
)
fpillet commented 5 years ago

Yes the problem is with the last two arguments. It should be doing:

LogMessageF_va(
          logDetails.fileName,
          Int32(logDetails.lineNumber),
          logDetails.functionName,
          domain,
          Int32(convertLogLevel(logDetails.level)),
          "%@",
          getVaList([logDetails.message])
)

Otherwise the % signs in your message are interpreted as formatting arguments

NeverwinterMoon commented 5 years ago

@fpillet Thank you so very much. It works nicely now!