Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move clipboard debug message to own scope #8

Merged
merged 1 commit into from
May 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions libweston/backend-rdp/rdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2054,14 +2054,16 @@ rdp_backend_create(struct weston_compositor *compositor,
"rdp-backend",
"Debug messages from RDP backend\n",
NULL, NULL, NULL);
s = getenv("WESTON_RDP_DEBUG_LEVEL");
if (s) {
if (!safe_strtoint(s, &b->debugLevel))
if (b->debug) {
s = getenv("WESTON_RDP_DEBUG_LEVEL");
if (s) {
if (!safe_strtoint(s, &b->debugLevel))
b->debugLevel = RDP_DEBUG_LEVEL_DEFAULT;
else if (b->debugLevel > RDP_DEBUG_LEVEL_VERBOSE)
b->debugLevel = RDP_DEBUG_LEVEL_VERBOSE;
} else {
b->debugLevel = RDP_DEBUG_LEVEL_DEFAULT;
else if (b->debugLevel > RDP_DEBUG_LEVEL_VERBOSE)
b->debugLevel = RDP_DEBUG_LEVEL_VERBOSE;
} else {
b->debugLevel = RDP_DEBUG_LEVEL_DEFAULT;
}
}
weston_log("RDP backend: WESTON_RDP_DEBUG_LEVEL: %d\n", b->debugLevel);
/* After here, rdp_debug() is ready to be used */
Expand Down Expand Up @@ -2186,6 +2188,8 @@ rdp_backend_create(struct weston_compositor *compositor,
err_compositor:
weston_compositor_shutdown(compositor);
err_free_strings:
if (b->debug)
weston_log_scope_destroy(b->debug);
free(b->rdp_key);
free(b->server_cert);
free(b->server_key);
Expand Down
52 changes: 32 additions & 20 deletions libweston/backend-rdp/rdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ struct rdp_backend {
uint32_t head_index;
struct weston_log_scope *debug;
uint32_t debugLevel;
struct weston_log_scope *debugClipboard;
uint32_t debugClipboardLevel;

char *server_cert;
char *server_key;
Expand Down Expand Up @@ -379,26 +381,35 @@ typedef struct rdp_peer_context RdpPeerContext;

#define RDP_DEBUG_LEVEL_DEFAULT RDP_DEBUG_LEVEL_INFO

/* Ideally here should use weston_log_scope_printf() instead of weston_log()
since weston_log() requires "log" scope to be enabled, but weston_log()
added timestamp which is often helpful, thus use weston_log() here.

To enable rdp_debug message, add "--logger-scopes=rdp-backend,log" to
weston's command line, this added rdp-backend and log scopes */
/* TODO: support debug level */
#define rdp_debug_level(b, cont, lvl, ...) \
if ((b) && (b)->debug && ((b)->debugLevel >= (lvl)) && weston_log_scope_is_enabled((b)->debug)) { \
if (cont) \
weston_log_continue(__VA_ARGS__); \
else \
weston_log(__VA_ARGS__); \
}

#define rdp_debug_verbose(b, ...) rdp_debug_level(b, FALSE, RDP_DEBUG_LEVEL_VERBOSE, __VA_ARGS__)
#define rdp_debug(b, ...) rdp_debug_level(b, FALSE, RDP_DEBUG_LEVEL_INFO, __VA_ARGS__)

#define rdp_debug_verbose_continue(b, ...) rdp_debug_level(b, TRUE, RDP_DEBUG_LEVEL_VERBOSE, __VA_ARGS__)
#define rdp_debug_continue(b, ...) rdp_debug_level(b, TRUE, RDP_DEBUG_LEVEL_INFO, __VA_ARGS__)
/* To enable rdp_debug message, add "--logger-scopes=rdp-backend". */
#define rdp_debug_verbose(b, ...) \
if (b->debugLevel >= RDP_DEBUG_LEVEL_VERBOSE) \
rdp_debug_print(b->debug, false, __VA_ARGS__)
#define rdp_debug_verbose_continue(b, ...) \
if (b->debugLevel >= RDP_DEBUG_LEVEL_VERBOSE) \
rdp_debug_print(b->debug, true, __VA_ARGS__)
#define rdp_debug(b, ...) \
if (b->debugLevel >= RDP_DEBUG_LEVEL_INFO) \
rdp_debug_print(b->debug, false, __VA_ARGS__)
#define rdp_debug_continue(b, ...) \
if (b->debugLevel >= RDP_DEBUG_LEVEL_INFO) \
rdp_debug_print(b->debug, true, __VA_ARGS__)

/* To enable rdp_debug_clipboard message, add "--logger-scopes=rdp-backend-clipboard". */
#define rdp_debug_clipboard_verbose(b, ...) \
if (b->debugClipboardLevel >= RDP_DEBUG_LEVEL_VERBOSE) \
rdp_debug_print(b->debugClipboard, false, __VA_ARGS__)
#define rdp_debug_clipboard_verbose_continue(b, ...) \
if (b->debugClipboardLevel >= RDP_DEBUG_LEVEL_VERBOSE) \
rdp_debug_print(b->debugClipboard, true, __VA_ARGS__)
#define rdp_debug_clipboard(b, ...) \
if (b->debugClipboardLevel >= RDP_DEBUG_LEVEL_INFO) \
rdp_debug_print(b->debugClipboard, false, __VA_ARGS__)
#define rdp_debug_clipboard_continue(b, ...) \
if (b->debugClipboardLevel >= RDP_DEBUG_LEVEL_INFO) \
rdp_debug_print(b->debugClipboard, true, __VA_ARGS__)

/* To enable rdp_debug message, add "--logger-scopes=rdp-backend". */

// rdp.c
void convert_rdp_keyboard_to_xkb_rule_names(UINT32 KeyboardType, UINT32 KeyboardLayout, struct xkb_rule_names *xkbRuleNames);
Expand All @@ -407,6 +418,7 @@ void rdp_head_destroy(struct weston_compositor *compositor, struct rdp_head *hea

// rdputil.c
pid_t rdp_get_tid(void);
void rdp_debug_print(struct weston_log_scope *log_scope, bool cont, char *fmt, ...);
#ifdef ENABLE_RDP_THREAD_CHECK
void assert_compositor_thread(struct rdp_backend *b);
void assert_not_compositor_thread(struct rdp_backend *b);
Expand Down
Loading