Patchwork lib: fwts_log_json: enable json human readable formatting (LP: #1206290)

login
register
mail settings
Submitter Colin King
Date July 29, 2013, 10:31 p.m.
Message ID <1375137119-18153-1-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/263089/
State Rejected
Headers show

Comments

Colin King - July 29, 2013, 10:31 p.m.
From: Colin Ian King <colin.king@canonical.com>

The current json log output is hard to read as a human. Enable the json
pretty printing to make it easier for mortals to parse by eye.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_log_json.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Alex Hung - Aug. 1, 2013, 7:57 a.m.
On 07/30/2013 06:31 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The current json log output is hard to read as a human. Enable the json
> pretty printing to make it easier for mortals to parse by eye.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/src/fwts_log_json.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_log_json.c b/src/lib/src/fwts_log_json.c
> index a67bc3a..15b28bd 100644
> --- a/src/lib/src/fwts_log_json.c
> +++ b/src/lib/src/fwts_log_json.c
> @@ -216,7 +216,8 @@ static void fwts_log_close_json(fwts_log_file *log_file)
>
>   	fwts_log_section_end_json(log_file);
>
> -	str = json_object_to_json_string(json_stack[0].obj);
> +	str = json_object_to_json_string_ext(
> +		json_stack[0].obj, JSON_C_TO_STRING_PRETTY);
>   	if (str == NULL) {
>   		/* Let's not make this bail out as user may be logging to other files too */
>   		fprintf(stderr, "Cannot turn json object to text for output. Empty json output\n");
>

Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu - Aug. 2, 2013, 3:22 a.m.
On 07/30/2013 06:31 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The current json log output is hard to read as a human. Enable the json
> pretty printing to make it easier for mortals to parse by eye.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/src/fwts_log_json.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_log_json.c b/src/lib/src/fwts_log_json.c
> index a67bc3a..15b28bd 100644
> --- a/src/lib/src/fwts_log_json.c
> +++ b/src/lib/src/fwts_log_json.c
> @@ -216,7 +216,8 @@ static void fwts_log_close_json(fwts_log_file *log_file)
>
>   	fwts_log_section_end_json(log_file);
>
> -	str = json_object_to_json_string(json_stack[0].obj);
> +	str = json_object_to_json_string_ext(
> +		json_stack[0].obj, JSON_C_TO_STRING_PRETTY);
>   	if (str == NULL) {
>   		/* Let's not make this bail out as user may be logging to other files too */
>   		fprintf(stderr, "Cannot turn json object to text for output. Empty json output\n");
>


Can't find json_object_to_json_string_ext, am I missing some patches?

Ivan
Colin King - Aug. 2, 2013, 6:08 a.m.
On 02/08/13 04:22, IvanHu wrote:
> On 07/30/2013 06:31 AM, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> The current json log output is hard to read as a human. Enable the json
>> pretty printing to make it easier for mortals to parse by eye.
>>
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>   src/lib/src/fwts_log_json.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/lib/src/fwts_log_json.c b/src/lib/src/fwts_log_json.c
>> index a67bc3a..15b28bd 100644
>> --- a/src/lib/src/fwts_log_json.c
>> +++ b/src/lib/src/fwts_log_json.c
>> @@ -216,7 +216,8 @@ static void fwts_log_close_json(fwts_log_file
>> *log_file)
>>
>>       fwts_log_section_end_json(log_file);
>>
>> -    str = json_object_to_json_string(json_stack[0].obj);
>> +    str = json_object_to_json_string_ext(
>> +        json_stack[0].obj, JSON_C_TO_STRING_PRETTY);
>>       if (str == NULL) {
>>           /* Let's not make this bail out as user may be logging to
>> other files too */
>>           fprintf(stderr, "Cannot turn json object to text for output.
>> Empty json output\n");
>>
>
>
> Can't find json_object_to_json_string_ext, am I missing some patches?
>
> Ivan
>
Which release are you building against?

Colin
Ivan Hu - Aug. 2, 2013, 7:16 a.m.
On 08/02/2013 02:08 PM, Colin Ian King wrote:
> On 02/08/13 04:22, IvanHu wrote:
>> On 07/30/2013 06:31 AM, Colin King wrote:
>>> From: Colin Ian King <colin.king@canonical.com>
>>>
>>> The current json log output is hard to read as a human. Enable the json
>>> pretty printing to make it easier for mortals to parse by eye.
>>>
>>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>>> ---
>>>   src/lib/src/fwts_log_json.c | 3 ++-
>>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/src/lib/src/fwts_log_json.c b/src/lib/src/fwts_log_json.c
>>> index a67bc3a..15b28bd 100644
>>> --- a/src/lib/src/fwts_log_json.c
>>> +++ b/src/lib/src/fwts_log_json.c
>>> @@ -216,7 +216,8 @@ static void fwts_log_close_json(fwts_log_file
>>> *log_file)
>>>
>>>       fwts_log_section_end_json(log_file);
>>>
>>> -    str = json_object_to_json_string(json_stack[0].obj);
>>> +    str = json_object_to_json_string_ext(
>>> +        json_stack[0].obj, JSON_C_TO_STRING_PRETTY);
>>>       if (str == NULL) {
>>>           /* Let's not make this bail out as user may be logging to
>>> other files too */
>>>           fprintf(stderr, "Cannot turn json object to text for output.
>>> Empty json output\n");
>>>
>>
>>
>> Can't find json_object_to_json_string_ext, am I missing some patches?
>>
>> Ivan
>>
> Which release are you building against?
>
> Colin
>

I try the latest version of fwts again, and apply the patch, then build,
got the build error:
l -Werror -Wextra -g -O2 -MT fwts_log_json.lo -MD -MP -MF 
.deps/fwts_log_json.Tpo -c fwts_log_json.c  -fPIC -DPIC -o 
.libs/fwts_log_json.o
fwts_log_json.c: In function 'fwts_log_close_json':
fwts_log_json.c:219:2: error: implicit declaration of function 
'json_object_to_json_string_ext' [-Werror=implicit-function-declaration]
fwts_log_json.c:220:22: error: 'JSON_C_TO_STRING_PRETTY' undeclared 
(first use in this function)
fwts_log_json.c:220:22: note: each undeclared identifier is reported 
only once for each function it appears in
cc1: all warnings being treated as errors
make[4]: *** [fwts_log_json.lo] Error 1
make[4]: Leaving directory `/home/work/fwts/src/lib/src'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/home/work/fwts/src/lib'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/work/fwts/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/work/fwts'
make: *** [all] Error 2

Ivan
Colin King - Aug. 2, 2013, 8:09 a.m.
On 02/08/13 08:16, IvanHu wrote:
> On 08/02/2013 02:08 PM, Colin Ian King wrote:
>> On 02/08/13 04:22, IvanHu wrote:
>>> On 07/30/2013 06:31 AM, Colin King wrote:
>>>> From: Colin Ian King <colin.king@canonical.com>
>>>>
>>>> The current json log output is hard to read as a human. Enable the json
>>>> pretty printing to make it easier for mortals to parse by eye.
>>>>
>>>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>>>> ---
>>>>   src/lib/src/fwts_log_json.c | 3 ++-
>>>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/src/lib/src/fwts_log_json.c b/src/lib/src/fwts_log_json.c
>>>> index a67bc3a..15b28bd 100644
>>>> --- a/src/lib/src/fwts_log_json.c
>>>> +++ b/src/lib/src/fwts_log_json.c
>>>> @@ -216,7 +216,8 @@ static void fwts_log_close_json(fwts_log_file
>>>> *log_file)
>>>>
>>>>       fwts_log_section_end_json(log_file);
>>>>
>>>> -    str = json_object_to_json_string(json_stack[0].obj);
>>>> +    str = json_object_to_json_string_ext(
>>>> +        json_stack[0].obj, JSON_C_TO_STRING_PRETTY);
>>>>       if (str == NULL) {
>>>>           /* Let's not make this bail out as user may be logging to
>>>> other files too */
>>>>           fprintf(stderr, "Cannot turn json object to text for output.
>>>> Empty json output\n");
>>>>
>>>
>>>
>>> Can't find json_object_to_json_string_ext, am I missing some patches?
>>>
>>> Ivan
>>>
>> Which release are you building against?

-EAGAIN,

which release (of Ubuntu) are you building it in?

>>
>> Colin
>>
>
> I try the latest version of fwts again, and apply the patch, then build,
> got the build error:
> l -Werror -Wextra -g -O2 -MT fwts_log_json.lo -MD -MP -MF
> .deps/fwts_log_json.Tpo -c fwts_log_json.c  -fPIC -DPIC -o
> .libs/fwts_log_json.o
> fwts_log_json.c: In function 'fwts_log_close_json':
> fwts_log_json.c:219:2: error: implicit declaration of function
> 'json_object_to_json_string_ext' [-Werror=implicit-function-declaration]
> fwts_log_json.c:220:22: error: 'JSON_C_TO_STRING_PRETTY' undeclared
> (first use in this function)
> fwts_log_json.c:220:22: note: each undeclared identifier is reported
> only once for each function it appears in
> cc1: all warnings being treated as errors
> make[4]: *** [fwts_log_json.lo] Error 1
> make[4]: Leaving directory `/home/work/fwts/src/lib/src'
> make[3]: *** [all-recursive] Error 1
> make[3]: Leaving directory `/home/work/fwts/src/lib'
> make[2]: *** [all-recursive] Error 1
> make[2]: Leaving directory `/home/work/fwts/src'
> make[1]: *** [all-recursive] Error 1
> make[1]: Leaving directory `/home/work/fwts'
> make: *** [all] Error 2
>
> Ivan
>
>
>
Ivan Hu - Aug. 2, 2013, 8:24 a.m.
On 08/02/2013 04:09 PM, Colin Ian King wrote:
> On 02/08/13 08:16, IvanHu wrote:
>> On 08/02/2013 02:08 PM, Colin Ian King wrote:
>>> On 02/08/13 04:22, IvanHu wrote:
>>>> On 07/30/2013 06:31 AM, Colin King wrote:
>>>>> From: Colin Ian King <colin.king@canonical.com>
>>>>>
>>>>> The current json log output is hard to read as a human. Enable the
>>>>> json
>>>>> pretty printing to make it easier for mortals to parse by eye.
>>>>>
>>>>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>>>>> ---
>>>>>   src/lib/src/fwts_log_json.c | 3 ++-
>>>>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/src/lib/src/fwts_log_json.c b/src/lib/src/fwts_log_json.c
>>>>> index a67bc3a..15b28bd 100644
>>>>> --- a/src/lib/src/fwts_log_json.c
>>>>> +++ b/src/lib/src/fwts_log_json.c
>>>>> @@ -216,7 +216,8 @@ static void fwts_log_close_json(fwts_log_file
>>>>> *log_file)
>>>>>
>>>>>       fwts_log_section_end_json(log_file);
>>>>>
>>>>> -    str = json_object_to_json_string(json_stack[0].obj);
>>>>> +    str = json_object_to_json_string_ext(
>>>>> +        json_stack[0].obj, JSON_C_TO_STRING_PRETTY);
>>>>>       if (str == NULL) {
>>>>>           /* Let's not make this bail out as user may be logging to
>>>>> other files too */
>>>>>           fprintf(stderr, "Cannot turn json object to text for output.
>>>>> Empty json output\n");
>>>>>
>>>>
>>>>
>>>> Can't find json_object_to_json_string_ext, am I missing some patches?
>>>>
>>>> Ivan
>>>>
>>> Which release are you building against?
>
> -EAGAIN,
>
> which release (of Ubuntu) are you building it in?
>
>>>
>>> Colin
>>>

Ubuntu 12.04.2 LTS
with kernel Ubuntu 12.04.2 LTS

Ivan

>>
>> I try the latest version of fwts again, and apply the patch, then build,
>> got the build error:
>> l -Werror -Wextra -g -O2 -MT fwts_log_json.lo -MD -MP -MF
>> .deps/fwts_log_json.Tpo -c fwts_log_json.c  -fPIC -DPIC -o
>> .libs/fwts_log_json.o
>> fwts_log_json.c: In function 'fwts_log_close_json':
>> fwts_log_json.c:219:2: error: implicit declaration of function
>> 'json_object_to_json_string_ext' [-Werror=implicit-function-declaration]
>> fwts_log_json.c:220:22: error: 'JSON_C_TO_STRING_PRETTY' undeclared
>> (first use in this function)
>> fwts_log_json.c:220:22: note: each undeclared identifier is reported
>> only once for each function it appears in
>> cc1: all warnings being treated as errors
>> make[4]: *** [fwts_log_json.lo] Error 1
>> make[4]: Leaving directory `/home/work/fwts/src/lib/src'
>> make[3]: *** [all-recursive] Error 1
>> make[3]: Leaving directory `/home/work/fwts/src/lib'
>> make[2]: *** [all-recursive] Error 1
>> make[2]: Leaving directory `/home/work/fwts/src'
>> make[1]: *** [all-recursive] Error 1
>> make[1]: Leaving directory `/home/work/fwts'
>> make: *** [all] Error 2
>>
>> Ivan
>>
>>
>>
>
>
Ivan Hu - Aug. 2, 2013, 8:31 a.m.
On 08/02/2013 04:24 PM, IvanHu wrote:
> On 08/02/2013 04:09 PM, Colin Ian King wrote:
>> On 02/08/13 08:16, IvanHu wrote:
>>> On 08/02/2013 02:08 PM, Colin Ian King wrote:
>>>> On 02/08/13 04:22, IvanHu wrote:
>>>>> On 07/30/2013 06:31 AM, Colin King wrote:
>>>>>> From: Colin Ian King <colin.king@canonical.com>
>>>>>>
>>>>>> The current json log output is hard to read as a human. Enable the
>>>>>> json
>>>>>> pretty printing to make it easier for mortals to parse by eye.
>>>>>>
>>>>>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>>>>>> ---
>>>>>>   src/lib/src/fwts_log_json.c | 3 ++-
>>>>>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>>>>>
>>>>>> diff --git a/src/lib/src/fwts_log_json.c
>>>>>> b/src/lib/src/fwts_log_json.c
>>>>>> index a67bc3a..15b28bd 100644
>>>>>> --- a/src/lib/src/fwts_log_json.c
>>>>>> +++ b/src/lib/src/fwts_log_json.c
>>>>>> @@ -216,7 +216,8 @@ static void fwts_log_close_json(fwts_log_file
>>>>>> *log_file)
>>>>>>
>>>>>>       fwts_log_section_end_json(log_file);
>>>>>>
>>>>>> -    str = json_object_to_json_string(json_stack[0].obj);
>>>>>> +    str = json_object_to_json_string_ext(
>>>>>> +        json_stack[0].obj, JSON_C_TO_STRING_PRETTY);
>>>>>>       if (str == NULL) {
>>>>>>           /* Let's not make this bail out as user may be logging to
>>>>>> other files too */
>>>>>>           fprintf(stderr, "Cannot turn json object to text for
>>>>>> output.
>>>>>> Empty json output\n");
>>>>>>
>>>>>
>>>>>
>>>>> Can't find json_object_to_json_string_ext, am I missing some patches?
>>>>>
>>>>> Ivan
>>>>>
>>>> Which release are you building against?
>>
>> -EAGAIN,
>>
>> which release (of Ubuntu) are you building it in?
>>
>>>>
>>>> Colin
>>>>
>
> Ubuntu 12.04.2 LTS
> with kernel Ubuntu 12.04.2 LTS
sorry typo,
kernel version, 3.5.0-37-generic
>
> Ivan
>
>>>
>>> I try the latest version of fwts again, and apply the patch, then build,
>>> got the build error:
>>> l -Werror -Wextra -g -O2 -MT fwts_log_json.lo -MD -MP -MF
>>> .deps/fwts_log_json.Tpo -c fwts_log_json.c  -fPIC -DPIC -o
>>> .libs/fwts_log_json.o
>>> fwts_log_json.c: In function 'fwts_log_close_json':
>>> fwts_log_json.c:219:2: error: implicit declaration of function
>>> 'json_object_to_json_string_ext' [-Werror=implicit-function-declaration]
>>> fwts_log_json.c:220:22: error: 'JSON_C_TO_STRING_PRETTY' undeclared
>>> (first use in this function)
>>> fwts_log_json.c:220:22: note: each undeclared identifier is reported
>>> only once for each function it appears in
>>> cc1: all warnings being treated as errors
>>> make[4]: *** [fwts_log_json.lo] Error 1
>>> make[4]: Leaving directory `/home/work/fwts/src/lib/src'
>>> make[3]: *** [all-recursive] Error 1
>>> make[3]: Leaving directory `/home/work/fwts/src/lib'
>>> make[2]: *** [all-recursive] Error 1
>>> make[2]: Leaving directory `/home/work/fwts/src'
>>> make[1]: *** [all-recursive] Error 1
>>> make[1]: Leaving directory `/home/work/fwts'
>>> make: *** [all] Error 2
>>>
>>> Ivan
>>>
>>>
>>>
>>
>>
>
>

Patch

diff --git a/src/lib/src/fwts_log_json.c b/src/lib/src/fwts_log_json.c
index a67bc3a..15b28bd 100644
--- a/src/lib/src/fwts_log_json.c
+++ b/src/lib/src/fwts_log_json.c
@@ -216,7 +216,8 @@  static void fwts_log_close_json(fwts_log_file *log_file)
 
 	fwts_log_section_end_json(log_file);
 
-	str = json_object_to_json_string(json_stack[0].obj);
+	str = json_object_to_json_string_ext(
+		json_stack[0].obj, JSON_C_TO_STRING_PRETTY);
 	if (str == NULL) {
 		/* Let's not make this bail out as user may be logging to other files too */
 		fprintf(stderr, "Cannot turn json object to text for output. Empty json output\n");