mirror of
https://github.com/cage-kiosk/cage.git
synced 2025-10-29 05:40:19 -04:00
Add CLI flag to enable debug logs
For bug reports, it's useful to ask for a debug log. However there's no way for users to enable debug logs without recompiling. Add a CLI flag to do so.
This commit is contained in:
parent
0208f565dc
commit
852839e59f
3 changed files with 17 additions and 7 deletions
|
|
@ -6,7 +6,7 @@ cage - a Wayland kiosk compositor
|
||||||
|
|
||||||
# SYNOPSIS
|
# SYNOPSIS
|
||||||
|
|
||||||
*cage* [-dhmrsv] [--] _application_ [application argument ...]
|
*cage* [options...] [--] _application_ [application argument ...]
|
||||||
|
|
||||||
# DESCRIPTION
|
# DESCRIPTION
|
||||||
|
|
||||||
|
|
@ -19,6 +19,9 @@ activities outside the scope of the running application are prevented.
|
||||||
*-d*
|
*-d*
|
||||||
Don't draw client side decorations when possible.
|
Don't draw client side decorations when possible.
|
||||||
|
|
||||||
|
*-D*
|
||||||
|
Enable debug logging.
|
||||||
|
|
||||||
*-h*
|
*-h*
|
||||||
Show the help message.
|
Show the help message.
|
||||||
|
|
||||||
|
|
|
||||||
16
cage.c
16
cage.c
|
|
@ -227,6 +227,7 @@ usage(FILE *file, const char *cage)
|
||||||
"Usage: %s [OPTIONS] [--] APPLICATION\n"
|
"Usage: %s [OPTIONS] [--] APPLICATION\n"
|
||||||
"\n"
|
"\n"
|
||||||
" -d\t Don't draw client side decorations, when possible\n"
|
" -d\t Don't draw client side decorations, when possible\n"
|
||||||
|
" -D\t Enable debug logging\n"
|
||||||
" -h\t Display this help message\n"
|
" -h\t Display this help message\n"
|
||||||
" -m extend Extend the display across all connected outputs (default)\n"
|
" -m extend Extend the display across all connected outputs (default)\n"
|
||||||
" -m last Use only the last connected output\n"
|
" -m last Use only the last connected output\n"
|
||||||
|
|
@ -246,6 +247,9 @@ parse_args(struct cg_server *server, int argc, char *argv[])
|
||||||
case 'd':
|
case 'd':
|
||||||
server->xdg_decoration = true;
|
server->xdg_decoration = true;
|
||||||
break;
|
break;
|
||||||
|
case 'D':
|
||||||
|
server->log_level = WLR_DEBUG;
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
usage(stdout, argv[0]);
|
usage(stdout, argv[0]);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -279,20 +283,20 @@ parse_args(struct cg_server *server, int argc, char *argv[])
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct cg_server server = {0};
|
struct cg_server server = {.log_level = WLR_INFO};
|
||||||
struct wl_event_source *sigchld_source = NULL;
|
struct wl_event_source *sigchld_source = NULL;
|
||||||
pid_t pid = 0;
|
pid_t pid = 0;
|
||||||
int ret = 0, app_ret = 0;
|
int ret = 0, app_ret = 0;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
server.log_level = WLR_DEBUG;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!parse_args(&server, argc, argv)) {
|
if (!parse_args(&server, argc, argv)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
wlr_log_init(server.log_level, NULL);
|
||||||
wlr_log_init(WLR_DEBUG, NULL);
|
|
||||||
#else
|
|
||||||
wlr_log_init(WLR_ERROR, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Wayland requires XDG_RUNTIME_DIR to be set. */
|
/* Wayland requires XDG_RUNTIME_DIR to be set. */
|
||||||
if (!getenv("XDG_RUNTIME_DIR")) {
|
if (!getenv("XDG_RUNTIME_DIR")) {
|
||||||
|
|
|
||||||
3
server.h
3
server.h
|
|
@ -9,6 +9,8 @@
|
||||||
#include <wlr/types/wlr_output_layout.h>
|
#include <wlr/types/wlr_output_layout.h>
|
||||||
#include <wlr/types/wlr_relative_pointer_v1.h>
|
#include <wlr/types/wlr_relative_pointer_v1.h>
|
||||||
#include <wlr/types/wlr_xdg_decoration_v1.h>
|
#include <wlr/types/wlr_xdg_decoration_v1.h>
|
||||||
|
#include <wlr/util/log.h>
|
||||||
|
|
||||||
#if CAGE_HAS_XWAYLAND
|
#if CAGE_HAS_XWAYLAND
|
||||||
#include <wlr/xwayland.h>
|
#include <wlr/xwayland.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -63,6 +65,7 @@ struct cg_server {
|
||||||
bool allow_vt_switch;
|
bool allow_vt_switch;
|
||||||
bool return_app_code;
|
bool return_app_code;
|
||||||
bool terminated;
|
bool terminated;
|
||||||
|
enum wlr_log_importance log_level;
|
||||||
};
|
};
|
||||||
|
|
||||||
void server_terminate(struct cg_server *server);
|
void server_terminate(struct cg_server *server);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue