On Fri, Oct 11, 2019 at 06:55:42PM +0800, Halley Zhao via gnome-shell-list wrote: > Hi experts: > I want to debug somthing in mutter, the question is how to add log in > mutter? > > the background is: > 1. > on my platform(fc30), weston-simple-dmabuf-drm fail to run, it fails after > call zwp_linux_buffer_params_v1_create(). > after export WAYLAND_DEBUG=1, I don't get clue. > " > (create_dmabuf_buffer, 711) > (create_dmabuf_buffer,723)format: XR24, width: 256, height: 256, flags: 0x0 > Error: zwp_linux_buffer_params.create failed. > Error: zwp_linux_buffer_params.create failed. > Error: zwp_linux_buffer_params.create failed. > " > 2. > then I decide to add some log in mutter to see where is the fail. > since libmutter-2.0.so is loaded by gnome-shell in the background, I try to > write my debug log to disk file. but when I add some log in dma_buf_bind(), > it doesn't take effect. why? > what's the correct way to add log in mutter?
You should be able to use e.g. fprintf (stderr, "Log this message\n"); , g_message ("Log this message"); or g_warning ("Log this warning"); If you run gnome-shell or mutter from GDM, the log entries will end up in the journal. You can look in the journal with for example journalctl -e $(which gnome-shell) If you run mutter or gnome-shell manually from a tty, it's easiest to run and reroute stdout and stderr directly to a file, e.g mutter >& mutter.log. If your added log entries doesn't show up even though you are sure the functions where you added your log entries were called, then double check that the libmutter you compiled yourself is the one used by the executable when you run. Jonas > thanks > > here are code piece to add log: > static void _my_print_test_log(const char* file_name) > { > FILE* _tmp_fp = NULL; > _tmp_fp = fopen(file_name, "w+"); > if (_tmp_fp) { > fprintf(_tmp_fp, "#### my test ####"); > fclose(_tmp_fp); > } > } > > static void > dma_buf_bind (struct wl_client *client, > void *data, > uint32_t version, > uint32_t id) > { > MetaWaylandCompositor *compositor = data; > struct wl_resource *resource; > > PRINT_MARK; > resource = wl_resource_create (client, &zwp_linux_dmabuf_v1_interface, > version, id); > wl_resource_set_implementation (resource, &dma_buf_implementation, > compositor, NULL); > > _my_print_test_log("/tmp/my_mutter_001.txt"); > > send_modifiers (resource, DRM_FORMAT_ARGB8888); > send_modifiers (resource, DRM_FORMAT_XRGB8888); > send_modifiers (resource, DRM_FORMAT_ARGB2101010); > send_modifiers (resource, DRM_FORMAT_RGB565); > } > _______________________________________________ > gnome-shell-list mailing list > gnome-shell-list@gnome.org > https://mail.gnome.org/mailman/listinfo/gnome-shell-list _______________________________________________ gnome-shell-list mailing list gnome-shell-list@gnome.org https://mail.gnome.org/mailman/listinfo/gnome-shell-list