From 4dbd8bbefac5ad695271541cc186fa3e1db984e8 Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 22 Aug 2012 00:30:24 +0100 Subject: [PATCH] Added some logging and updated man page --- docs/profanity.1 | 36 ++++++++++++++++++++++++++++++++++-- src/chat_log.c | 3 +++ src/command.c | 1 + src/contact_list.c | 2 ++ src/jabber.c | 6 ++++++ src/log.c | 1 - src/preferences.c | 2 ++ src/profanity.c | 15 ++++++++++----- src/windows.c | 4 ++++ 9 files changed, 62 insertions(+), 8 deletions(-) diff --git a/docs/profanity.1 b/docs/profanity.1 index edf191fd..6fbf80bd 100644 --- a/docs/profanity.1 +++ b/docs/profanity.1 @@ -1,6 +1,10 @@ .TH Profanity 1 "August 2012" "Profanity XMPP client" .SH NAME -Profanity \- a simple console based XMPP chat client for Linux +Profanity \- a simple console based XMPP chat client for Linux, see the homepage +at: +.br +.PP + .SH SYNOPSIS .B profanity [-vhd] [-l level] @@ -119,7 +123,35 @@ forground or background colour on your terminal. The [connections] section is the list of users that will appear in tab completion for the /connect command. This list is automatically populated when you successfully log in as a user. +.SH BUGS +Bugs can either be reported by sending a mail directly to: +.br +.PP + +.br +.PP +or to the mailing list at: +.br +.PP + +.br +.PP +or with a Github account by logging issues on the issue tracker at: +.br +.PP + +.SH LICENSE +Copyright (C) 2012 James Booth . +License GPLv3+: GNU GPL version 3 or later +This is free software; you are free to change and redistribute it. +There is NO WARRANTY, to the extent permitted by law. .SH AUTHORS/CREDITS .B Profanity was written by James Booth -.B +.B +with contributions from: +.br +.PP +Dolan O'Toole +.br +Colin Bradley diff --git a/src/chat_log.c b/src/chat_log.c index 56240787..955e49ad 100644 --- a/src/chat_log.c +++ b/src/chat_log.c @@ -28,6 +28,7 @@ #include "chat_log.h" #include "common.h" #include "util.h" +#include "log.h" static GHashTable *logs; static GTimeZone *tz; @@ -37,6 +38,7 @@ static void _close_file(gpointer key, gpointer value, gpointer user_data); void chat_log_init(void) { + log_msg(PROF_LEVEL_INFO, "prof", "Initialising chat logs"); tz = g_time_zone_new_local(); logs = g_hash_table_new(NULL, (GEqualFunc) g_strcmp0); } @@ -86,6 +88,7 @@ chat_log_chat(const char * const login, char *other, void chat_log_close(void) { + log_msg(PROF_LEVEL_INFO, "prof", "Closing down chat logs"); g_hash_table_foreach(logs, (GHFunc) _close_file, NULL); g_time_zone_unref(tz); } diff --git a/src/command.c b/src/command.c index 3fffef02..0daae3ef 100644 --- a/src/command.c +++ b/src/command.c @@ -360,6 +360,7 @@ process_input(char *inp) void command_init(void) { + log_msg(PROF_LEVEL_INFO, "prof", "Initialising commands"); commands_ac = p_autocomplete_new(); unsigned int i; diff --git a/src/contact_list.c b/src/contact_list.c index b244ac3e..485a7a35 100644 --- a/src/contact_list.c +++ b/src/contact_list.c @@ -29,12 +29,14 @@ #include "contact.h" #include "contact_list.h" #include "prof_autocomplete.h" +#include "log.h" static PAutocomplete ac; void contact_list_init(void) { + log_msg(PROF_LEVEL_INFO, "prof", "Initialising contact list"); ac = p_obj_autocomplete_new((PStrFunc)p_contact_name, (PCopyFunc)p_contact_copy, (PEqualDeepFunc)p_contacts_equal_deep, diff --git a/src/jabber.c b/src/jabber.c index 42dd959b..95a7f25a 100644 --- a/src/jabber.c +++ b/src/jabber.c @@ -111,6 +111,7 @@ static int _ping_timed_handler(xmpp_conn_t * const conn, void * const userdata); void jabber_init(const int disable_tls) { + log_msg(PROF_LEVEL_INFO, "prof", "Initialising XMPP"); jabber_conn.conn_status = JABBER_STARTED; jabber_conn.presence = PRESENCE_OFFLINE; jabber_conn.tls_disabled = disable_tls; @@ -126,6 +127,7 @@ jabber_conn_status_t jabber_connect(const char * const user, const char * const passwd) { + log_msg(PROF_LEVEL_INFO, "prof", "Connecting as %s", user); xmpp_initialize(); jabber_conn.log = xmpp_get_file_logger(); @@ -159,6 +161,7 @@ void jabber_disconnect(void) { if (jabber_conn.conn_status == JABBER_CONNECTED) { + log_msg(PROF_LEVEL_INFO, "prof", "Closing connection"); xmpp_conn_release(jabber_conn.conn); xmpp_ctx_free(jabber_conn.ctx); xmpp_shutdown(); @@ -343,6 +346,7 @@ _jabber_conn_handler(xmpp_conn_t * const conn, title_bar_set_status(PRESENCE_ONLINE); cons_show(line); + log_msg(PROF_LEVEL_INFO, "prof", line); win_page_off(); status_bar_print_message(jid); status_bar_refresh(); @@ -366,9 +370,11 @@ _jabber_conn_handler(xmpp_conn_t * const conn, else { if (jabber_conn.conn_status == JABBER_CONNECTED) { cons_bad_show("Lost connection."); + log_msg(PROF_LEVEL_INFO, "prof", "Lost connection"); win_disconnected(); } else { cons_bad_show("Login failed."); + log_msg(PROF_LEVEL_INFO, "prof", "Login failed"); } win_page_off(); log_msg(PROF_LEVEL_INFO, CONN, "disconnected"); diff --git a/src/log.c b/src/log.c index 845d6a4d..b063f2b4 100644 --- a/src/log.c +++ b/src/log.c @@ -81,4 +81,3 @@ log_close(void) g_time_zone_unref(tz); fclose(logp); } - diff --git a/src/preferences.c b/src/preferences.c index 61b6b207..7aaed850 100644 --- a/src/preferences.c +++ b/src/preferences.c @@ -80,6 +80,7 @@ static void _save_prefs(void); void prefs_load(void) { + log_msg(PROF_LEVEL_INFO, "prof", "Loading preferences"); ac = p_autocomplete_new(); prefs_loc = g_string_new(getenv("HOME")); g_string_append(prefs_loc, "/.profanity/config"); @@ -109,6 +110,7 @@ prefs_load(void) void prefs_close(void) { + log_msg(PROF_LEVEL_INFO, "prof", "Closing down preferences"); g_key_file_free(prefs); } diff --git a/src/profanity.c b/src/profanity.c index b805e5b3..f8feedaf 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -26,6 +26,7 @@ #include +#include "config.h" #include "profanity.h" #include "log.h" #include "chat_log.h" @@ -36,7 +37,7 @@ #include "contact_list.h" #include "tinyurl.h" -static log_level_t get_log_level(char *log_level); +static log_level_t _get_log_level(char *log_level); static void _profanity_shutdown(void); void @@ -44,6 +45,8 @@ profanity_run(void) { gboolean cmd_result = TRUE; + log_msg(PROF_LEVEL_INFO, "prof", "Starting main event loop"); + inp_non_block(); while(cmd_result == TRUE) { int ch = ERR; @@ -73,9 +76,9 @@ void profanity_init(const int disable_tls, char *log_level) { create_config_directory(); - log_level_t prof_log_level = get_log_level(log_level); + log_level_t prof_log_level = _get_log_level(log_level); log_init(prof_log_level); - log_msg(PROF_LEVEL_INFO, PROF, "Starting Profanity..."); + log_msg(PROF_LEVEL_INFO, PROF, "Starting Profanity (%s)...", PACKAGE_VERSION); chat_log_init(); prefs_load(); gui_init(); @@ -91,12 +94,14 @@ _profanity_shutdown(void) log_msg(PROF_LEVEL_INFO, PROF, "Profanity is shutting down."); jabber_disconnect(); gui_close(); - log_close(); chat_log_close(); prefs_close(); + log_msg(PROF_LEVEL_INFO, "prof", "Shutdown complete"); + log_close(); } -static log_level_t get_log_level(char *log_level) +static log_level_t +_get_log_level(char *log_level) { if (strcmp(log_level, "DEBUG") == 0) { return PROF_LEVEL_DEBUG; diff --git a/src/windows.c b/src/windows.c index c8abb0c2..30f7e4fa 100644 --- a/src/windows.c +++ b/src/windows.c @@ -36,6 +36,7 @@ #include "command.h" #include "preferences.h" #include "tinyurl.h" +#include "log.h" #define CONS_WIN_TITLE "_cons" #define PAD_SIZE 200 @@ -84,6 +85,7 @@ static void _win_notify_typing(char * short_from); void gui_init(void) { + log_msg(PROF_LEVEL_INFO, "prof", "Initialising UI"); initscr(); cbreak(); keypad(stdscr, TRUE); @@ -135,12 +137,14 @@ gui_refresh(void) void gui_close(void) { + log_msg(PROF_LEVEL_INFO, "prof", "Closing UI"); endwin(); } void gui_resize(const int ch, const char * const input, const int size) { + log_msg(PROF_LEVEL_INFO, "prof", "Resizing UI"); title_bar_resize(); status_bar_resize(); _win_resize_all();