mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-18 17:46:21 +00:00
Added some logging and updated man page
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user