aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--degesch.c45
1 files changed, 18 insertions, 27 deletions
diff --git a/degesch.c b/degesch.c
index 3d0585d..f4fc87c 100644
--- a/degesch.c
+++ b/degesch.c
@@ -2749,6 +2749,18 @@ log_full (struct app_context *ctx, struct server *s, struct buffer *buffer,
#define log_server_error(s, buffer, ...) \
log_server ((s), (buffer), BUFFER_LINE_ERROR, __VA_ARGS__)
+#define log_global_debug(ctx, ...) \
+ BLOCK_START \
+ if (g_debug_mode) \
+ log_global ((ctx), 0, "(*) " __VA_ARGS__); \
+ BLOCK_END
+
+#define log_server_debug(s, ...) \
+ BLOCK_START \
+ if (g_debug_mode) \
+ log_server ((s), (s)->buffer, 0, "(*) " __VA_ARGS__); \
+ BLOCK_END
+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Lines that are used in more than one place
@@ -3377,7 +3389,7 @@ irc_send (struct server *s, const char *format, ...)
{
if (!soft_assert (irc_is_connected (s)))
{
- print_debug ("tried sending a message to a dead server connection");
+ log_server_debug (s, "sending a message to a dead server connection");
return;
}
@@ -3392,19 +3404,7 @@ irc_send (struct server *s, const char *format, ...)
str_append_vprintf (&str, format, ap);
va_end (ap);
- if (g_debug_mode)
- {
- input_hide (&s->ctx->input);
-
- char *server_name =
- iconv_xstrdup (s->ctx->term_from_utf8, s->name, -1, NULL);
- char *term = irc_to_term (s->ctx, str.str);
- fprintf (stderr, "[%s] <== \"%s\"\n", server_name, term);
- free (term);
- free (server_name);
-
- input_show (&s->ctx->input);
- }
+ log_server_debug (s, "#a<< \"#S\"#r", ATTR_PART, str.str);
str_append_str (&s->write_buffer, &str);
str_free (&str);
@@ -5939,19 +5939,7 @@ irc_process_message (const struct irc_message *msg,
{
struct server *s = user_data;
- if (g_debug_mode)
- {
- input_hide (&s->ctx->input);
-
- char *server_name =
- iconv_xstrdup (s->ctx->term_from_utf8, s->name, -1, NULL);
- char *term = irc_to_term (s->ctx, raw);
- fprintf (stderr, "[%s] ==> \"%s\"\n", server_name, term);
- free (term);
- free (server_name);
-
- input_show (&s->ctx->input);
- }
+ log_server_debug (s, "#a>> \"#S\"#r", ATTR_JOIN, raw);
struct irc_handler key = { .name = msg->command };
struct irc_handler *handler = bsearch (&key, g_irc_handlers,
@@ -7759,6 +7747,9 @@ process_input_utf8 (struct app_context *ctx, char *input, int alias_level)
return;
char *expanded = expand_alias (ctx, name, input);
+ if (expanded)
+ log_global_debug (ctx, "Alias expanded to \"#s\"", expanded);
+
if (!expanded)
log_global_error (ctx, "#s: /#s", "No such command or alias", name);
else if (alias_level != 0)