mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-25 23:26:22 +00:00
Added /log where command
This commit is contained in:
@@ -639,10 +639,11 @@ static struct cmd_t command_defs[] =
|
|||||||
NULL } } },
|
NULL } } },
|
||||||
|
|
||||||
{ "/log",
|
{ "/log",
|
||||||
cmd_log, parse_args, 2, 2, &cons_log_setting,
|
cmd_log, parse_args, 1, 2, &cons_log_setting,
|
||||||
{ "/log [property] [value]", "Manage system logging settings.",
|
{ "/log [property] [value]", "Manage system logging settings.",
|
||||||
{ "/log [property] [value]",
|
{ "/log [property] [value]",
|
||||||
"-----------------------",
|
"-----------------------",
|
||||||
|
"where : Show the current log file location.",
|
||||||
"Property may be one of:",
|
"Property may be one of:",
|
||||||
"rotate : Rotate log, accepts 'on' or 'off', defaults to 'on'.",
|
"rotate : Rotate log, accepts 'on' or 'off', defaults to 'on'.",
|
||||||
"maxsize : With rotate enabled, specifies the max log size, defaults to 1048580 (1MB).",
|
"maxsize : With rotate enabled, specifies the max log size, defaults to 1048580 (1MB).",
|
||||||
@@ -955,6 +956,7 @@ cmd_init(void)
|
|||||||
autocomplete_add(log_ac, "maxsize");
|
autocomplete_add(log_ac, "maxsize");
|
||||||
autocomplete_add(log_ac, "rotate");
|
autocomplete_add(log_ac, "rotate");
|
||||||
autocomplete_add(log_ac, "shared");
|
autocomplete_add(log_ac, "shared");
|
||||||
|
autocomplete_add(log_ac, "where");
|
||||||
|
|
||||||
autoaway_ac = autocomplete_new();
|
autoaway_ac = autocomplete_new();
|
||||||
autocomplete_add(autoaway_ac, "mode");
|
autocomplete_add(autoaway_ac, "mode");
|
||||||
|
|||||||
@@ -2287,6 +2287,10 @@ cmd_log(gchar **args, struct cmd_help_t help)
|
|||||||
int intval;
|
int intval;
|
||||||
|
|
||||||
if (strcmp(subcmd, "maxsize") == 0) {
|
if (strcmp(subcmd, "maxsize") == 0) {
|
||||||
|
if (value == NULL) {
|
||||||
|
cons_show("Usage: %s", help.usage);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
if (_strtoi(value, &intval, PREFS_MIN_LOG_SIZE, INT_MAX) == 0) {
|
if (_strtoi(value, &intval, PREFS_MIN_LOG_SIZE, INT_MAX) == 0) {
|
||||||
prefs_set_max_log_size(intval);
|
prefs_set_max_log_size(intval);
|
||||||
cons_show("Log maxinum size set to %d bytes", intval);
|
cons_show("Log maxinum size set to %d bytes", intval);
|
||||||
@@ -2298,22 +2302,24 @@ cmd_log(gchar **args, struct cmd_help_t help)
|
|||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
cons_show("Usage: %s", help.usage);
|
cons_show("Usage: %s", help.usage);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
|
||||||
return _cmd_set_boolean_preference(value, help,
|
|
||||||
"Log rotate", PREF_LOG_ROTATE);
|
|
||||||
}
|
}
|
||||||
|
return _cmd_set_boolean_preference(value, help, "Log rotate", PREF_LOG_ROTATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(subcmd, "shared") == 0) {
|
if (strcmp(subcmd, "shared") == 0) {
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
cons_show("Usage: %s", help.usage);
|
cons_show("Usage: %s", help.usage);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
|
||||||
gboolean result = _cmd_set_boolean_preference(value, help,
|
|
||||||
"Shared log", PREF_LOG_SHARED);
|
|
||||||
log_reinit();
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
gboolean result = _cmd_set_boolean_preference(value, help, "Shared log", PREF_LOG_SHARED);
|
||||||
|
log_reinit();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(subcmd, "where") == 0) {
|
||||||
|
char *logfile = get_log_file_location();
|
||||||
|
cons_show("Log file: %s", logfile);
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
cons_show("Usage: %s", help.usage);
|
cons_show("Usage: %s", help.usage);
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
#define PROF "prof"
|
#define PROF "prof"
|
||||||
|
|
||||||
static FILE *logp;
|
static FILE *logp;
|
||||||
|
GString *mainlogfile;
|
||||||
|
|
||||||
static GTimeZone *tz;
|
static GTimeZone *tz;
|
||||||
static GDateTime *dt;
|
static GDateTime *dt;
|
||||||
@@ -120,6 +121,7 @@ log_init(log_level_t filter)
|
|||||||
tz = g_time_zone_new_local();
|
tz = g_time_zone_new_local();
|
||||||
gchar *log_file = _get_main_log_file();
|
gchar *log_file = _get_main_log_file();
|
||||||
logp = fopen(log_file, "a");
|
logp = fopen(log_file, "a");
|
||||||
|
mainlogfile = g_string_new(log_file);
|
||||||
free(log_file);
|
free(log_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,6 +132,12 @@ log_reinit(void)
|
|||||||
log_init(level_filter);
|
log_init(level_filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
get_log_file_location(void)
|
||||||
|
{
|
||||||
|
return mainlogfile->str;
|
||||||
|
}
|
||||||
|
|
||||||
log_level_t
|
log_level_t
|
||||||
log_get_filter(void)
|
log_get_filter(void)
|
||||||
{
|
{
|
||||||
@@ -139,6 +147,7 @@ log_get_filter(void)
|
|||||||
void
|
void
|
||||||
log_close(void)
|
log_close(void)
|
||||||
{
|
{
|
||||||
|
g_string_free(mainlogfile, TRUE);
|
||||||
g_time_zone_unref(tz);
|
g_time_zone_unref(tz);
|
||||||
if (logp != NULL) {
|
if (logp != NULL) {
|
||||||
fclose(logp);
|
fclose(logp);
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ void log_init(log_level_t filter);
|
|||||||
log_level_t log_get_filter(void);
|
log_level_t log_get_filter(void);
|
||||||
void log_close(void);
|
void log_close(void);
|
||||||
void log_reinit(void);
|
void log_reinit(void);
|
||||||
|
char * get_log_file_location(void);
|
||||||
void log_debug(const char * const msg, ...);
|
void log_debug(const char * const msg, ...);
|
||||||
void log_info(const char * const msg, ...);
|
void log_info(const char * const msg, ...);
|
||||||
void log_warning(const char * const msg, ...);
|
void log_warning(const char * const msg, ...);
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include "command/command.h"
|
#include "command/command.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "log.h"
|
||||||
#include "roster_list.h"
|
#include "roster_list.h"
|
||||||
#include "config/preferences.h"
|
#include "config/preferences.h"
|
||||||
#include "config/theme.h"
|
#include "config/theme.h"
|
||||||
@@ -1222,6 +1223,7 @@ _cons_show_chat_prefs(void)
|
|||||||
static void
|
static void
|
||||||
_cons_log_setting(void)
|
_cons_log_setting(void)
|
||||||
{
|
{
|
||||||
|
cons_show("Log file location : %s", get_log_file_location());
|
||||||
cons_show("Max log size (/log maxsize) : %d bytes", prefs_get_max_log_size());
|
cons_show("Max log size (/log maxsize) : %d bytes", prefs_get_max_log_size());
|
||||||
|
|
||||||
if (prefs_get_boolean(PREF_LOG_ROTATE))
|
if (prefs_get_boolean(PREF_LOG_ROTATE))
|
||||||
|
|||||||
Reference in New Issue
Block a user