Fields names are not printed for C structures
shtirlic opened this issue · comments
Serg Podtynnyi commented
Here is the stock slog output:
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: programLevel})))
time=2024-01-05T02:18:08.689+07:00 level=DEBUG msg="XDGSurface SetData" x.data:=0x16e6cc0
time=2024-01-05T02:18:08.729+07:00 level=DEBUG msg=handleMapXDGToplevel topLevel={p:0x1786ba0}
time=2024-01-05T02:18:08.729+07:00 level=DEBUG msg=handleMapXDGToplevel s.topLevelList.Len()=0
time=2024-01-05T02:18:08.729+07:00 level=DEBUG msg=handleMapXDGToplevel s.topLevelList.Len()=1
time=2024-01-05T02:18:08.729+07:00 level=DEBUG msg=focusTopLevel "prev surface:"={p:<nil>}
time=2024-01-05T02:18:08.729+07:00 level=DEBUG msg=focusTopLevel "current surface:"={p:0x18598b0}
time=2024-01-05T02:18:08.729+07:00 level=DEBUG msg="XDGSurface SceneTree()" x.p="&{client:0x17c34c0 resource:0x16e75c0 surface:0x18598b0 link:{prev:0x17c34d8 next:0x17c34d8} role:1 role_resource:0x16e8a90 anon0:[160 107 120 1 0 0 0 0] popups:{prev:0x17c0680 next:0x17c0680} added:true configured:true configure_idle:<nil> scheduled_serial:1 configure_list:{prev:0x17c06a8 next:0x17c06a8} current:{configure_serial:1 geometry:{x:0 y:0 width:540 height:487}} pending:{configure_serial:1 geometry:{x:0 y:0 width:540 height:487}} initialized:true initial_commit:false events:{destroy:{listener_list:{prev:0x1574540 next:0x17c1430}} ping_timeout:{listener_list:{prev:0x17c06f8 next:0x17c06f8}} new_popup:{listener_list:{prev:0x17c0708 next:0x17c0708}} configure:{listener_list:{prev:0x17c0718 next:0x17c0718}} ack_configure:{listener_list:{prev:0x17c0728 next:0x17c0728}}} data:0x16e6cc0 role_resource_destroy:{link:{prev:0x16e8af0 next:0x16e8af0} notify:0x7fd40605ac90}}
This is output by stock tint
slog.SetDefault(slog.New(
tint.NewHandler(os.Stderr, &tint.Options{
Level: programLevel,
TimeFormat: time.TimeOnly,
}),
))
02:21:46 DBG XDGSurface SetData x.data:=0x2cdc520
02:21:46 DBG handleMapXDGToplevel topLevel={0x2db68c0}
02:21:46 DBG handleMapXDGToplevel s.topLevelList.Len()=0
02:21:46 DBG handleMapXDGToplevel s.topLevelList.Len()=1
02:21:46 DBG focusTopLevel "prev surface:"={<nil>}
02:21:46 DBG focusTopLevel "current surface:"={0x2d7d5a0}
02:21:46 DBG XDGSurface SceneTree() x.p="&{0x2ce6c10 0x2cdc960 0x2d7d5a0 {0x2ce6c28 0x2ce6c28} 1 0x2cec230 [192 104 219 2 0 0 0 0] {0x2de2770 0x2de2770} true true <nil> 1 {0x2de2798 0x2de2798} {1 {0 0 540 487}} {1 {0 0 540 487}} true false {{{0x2b6ae00 0x2ce86d0}} {{0x2de27e8 0x2de27e8}} {{0x2de27f8 0x2de27f8}} {{0x2de2808 0x2de2808}} {{0x2de2818 0x2de2818}}} 0x2cdc520 {{0x2cec290 0x2cec290} 0x7fc9cb193c90}}"
02:21:46 DBG XDGSurface SceneTree() x.p.data=0x2cdc520
see the XDGSurface SceneTree() x.p=
log line, in tint output there is no C structure fileds
lmittmann commented
Can you provide a simple example so I can reproduce the issue?
Serg Podtynnyi commented
Here the exmaple:
package main
import (
"log/slog"
"os"
"github.com/lmittmann/tint"
)
//
// struct test_struct {
// int testInt;
// char* myString;
// };
// struct test_struct tS;
//
// struct test_struct* test_struct(int i)
//{
// tS.testInt = i;
// tS.myString = "Hello";
// struct test_struct* ptr = &tS;
// return ptr;
// }
//
import "C"
type TestStructure struct {
p *C.struct_test_struct
}
func (t TestStructure) Init() TestStructure {
t.p = C.test_struct(1)
return t
}
func main() {
// tint slog
slog.SetDefault(slog.New(
tint.NewHandler(os.Stderr, &tint.Options{
Level: slog.LevelDebug})))
// stock slog
// slog.SetDefault(slog.New(
// slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{
// Level: slog.LevelDebug})))
tS := TestStructure{}.Init()
slog.Debug("test", "tS", tS)
slog.Info("test", "tS", tS.p)
}
with tint
Jan 5 16:28:42.531 DBG test tS={0x5bf160}
Jan 5 16:28:42.532 INF test tS="&{1 0x500ace}"
with stock slog
time=2024-01-05T16:28:57.514+07:00 level=DEBUG msg=test tS={p:0x5c1160}
time=2024-01-05T16:28:57.514+07:00 level=INFO msg=test tS="&{testInt:1 myString:0x501f7f}"
Serg Podtynnyi commented
JFYI it looks like %v
is used for output this structures instead of %+v