From cdf840fc68ace1f4befc78555a7f4f59d2c4d020 Mon Sep 17 00:00:00 2001 From: Doug Cone Date: Wed, 26 Jun 2024 02:17:25 -0400 Subject: [PATCH] refactor(print): encode functions in tables (#592) --- imports/print/shared.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/imports/print/shared.lua b/imports/print/shared.lua index a067dd1..305c9a0 100644 --- a/imports/print/shared.lua +++ b/imports/print/shared.lua @@ -17,7 +17,11 @@ local levelPrefixes = { local resourcePrintLevel = printLevel[GetConvar('ox:printlevel:' .. cache.resource, GetConvar('ox:printlevel', 'info'))] local template = ('^5[%s] %%s %%s^7'):format(cache.resource) -local jsonOptions = { sort_keys = true, indent = true } +local function handleException(reason, value) + if type(value) == 'function' then return tostring(value) end + return reason +end +local jsonOptions = { sort_keys = true, indent = true, exception = handleException } ---Prints to console conditionally based on what ox:printlevel is. ---Any print with a level more severe will also print. If ox:printlevel is info, then warn and error prints will appear as well, but debug prints will not.