overextended / ox_lib

A FiveM resource and script library for Lua and JS.
https://overextended.dev/ox_lib
GNU Lesser General Public License v3.0
282 stars 378 forks source link

fix(imports/logger): Loki encode does not work as expected #588

Closed Cata-a1138 closed 1 month ago

Cata-a1138 commented 1 month ago

Solve the problem that tags are converted to “table:xxx” by string.tostringall and therefore can't be encoded to json by encode. test code

lib.logger(-1, 'LogTest', 'Test String', 'test123:test123', 'rpname:Lena Meier', 'job:police')
lib.logger(-1, 'LogTest', 'Test Table', { rpname = "Lena Meier", job = "police" })

result 图片

SeaLife commented 1 month ago

Did you upgrade to Loki 3.0.0 or is this working on 2.8.x now as well? If not, we should probably mention this in the documentation or provide a additional loki2.8.x provider or smth. like that :) (Which is not in scope of this change i guess, just something we should consider)

//EDIT: Another thing we should consider, is this still working with other log providers? The user should not be forced to use Loki so using a table as a argument should work on all providers. (not checked, just another thing to consider)

thelindat commented 1 month ago

I've reverted the last change to loki logging due to backwards compatibility issues, and closing this just to avoid issues. Logging is long overdue for a rewrite and it will happen sometime after the nodejs 20 update.