예제 #1
0
파일: fe-log.c 프로젝트: ailin-nemui/irssi
/* SYNTAX: LOG STOP <id>|<file> */
static void cmd_log_stop(const char *data)
{
	LOG_REC *log;

	log = log_find_from_data(data);
	if (log == NULL || log->handle == -1)
		printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_LOG_NOT_OPEN, data);
	else {
		log_stop_logging(log);
		printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_LOG_CLOSED, data);
	}
}
예제 #2
0
파일: fe-log.c 프로젝트: ailin-nemui/irssi
/* SYNTAX: WINDOW LOG on|off|toggle [<filename>] */
static void cmd_window_log(const char *data)
{
	LOG_REC *log;
	char *set, *fname, window[MAX_INT_STRLEN];
	void *free_arg;
	int open_log, close_log;

	if (!cmd_get_params(data, &free_arg, 2, &set, &fname))
		return;

        ltoa(window, active_win->refnum);
	log = logs_find_item(LOG_ITEM_WINDOW_REFNUM, window, NULL, NULL);

        open_log = close_log = FALSE;
	if (g_ascii_strcasecmp(set, "ON") == 0)
		open_log = TRUE;
	else if (g_ascii_strcasecmp(set, "OFF") == 0) {
		close_log = TRUE;
	} else if (g_ascii_strcasecmp(set, "TOGGLE") == 0) {
                open_log = log == NULL;
                close_log = log != NULL;
	} else {
		printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_NOT_TOGGLE);
		cmd_params_free(free_arg);
		return;
	}

	if (open_log && log == NULL) {
		/* irc.log.<windowname> or irc.log.Window<ref#> */
		fname = *fname != '\0' ? g_strdup(fname) :
			g_strdup_printf("~/irc.log.%s%s",
					active_win->name != NULL ? active_win->name : "Window",
					active_win->name != NULL ? "" : window);
		log = log_create_rec(fname, MSGLEVEL_ALL);
		log->colorizer = log_colorizer_strip;
                log_item_add(log, LOG_ITEM_WINDOW_REFNUM, window, NULL);
		log_update(log);
		g_free(fname);
	}

	if (open_log && log != NULL) {
		log_start_logging(log);
		printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_LOG_OPENED, log->fname);
	} else if (close_log && log != NULL && log->handle != -1) {
		log_stop_logging(log);
		printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_LOG_CLOSED, log->fname);
	}

        cmd_params_free(free_arg);
}
예제 #3
0
파일: log.c 프로젝트: FabrizioFabbe/silc
static void log_destroy(LOG_REC *log)
{
	g_return_if_fail(log != NULL);

	if (log->handle != -1)
		log_stop_logging(log);

	logs = g_slist_remove(logs, log);
	signal_emit("log remove", 1, log);

	while (log->items != NULL)
		log_item_destroy(log, log->items->data);
	g_free(log->fname);
	g_free_not_null(log->real_fname);
	g_free(log);
}
예제 #4
0
파일: fe-log.c 프로젝트: svn2github/irssi
static void cmd_window_log(const char *data)
{
    /* /WINDOW LOG ON|OFF|TOGGLE [<filename>] */
    LOG_REC *log;
    char *params, *set, *fname, window[MAX_INT_STRLEN];
    int open_log, close_log;

    params = cmd_get_params(data, 2, &set, &fname);

    ltoa(window, active_win->refnum);
    log = log_find_item(window);

    open_log = close_log = FALSE;
    if (g_strcasecmp(set, "ON") == 0)
        open_log = TRUE;
    else if (g_strcasecmp(set, "OFF") == 0) {
        close_log = TRUE;
    } else if (g_strcasecmp(set, "TOGGLE") == 0) {
        open_log = log == NULL;
        close_log = log != NULL;
    } else {
        printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_NOT_TOGGLE);
        g_free(params);
        return;
    }

    if (open_log && log == NULL) {
        /* irc.log.<windowname> or irc.log.Window<ref#> */
        fname = *fname != '\0' ? g_strdup(fname) :
                g_strdup_printf("~/irc.log.%s%s",
                                active_win->name != NULL ? active_win->name : "Window",
                                active_win->name != NULL ? "" : window);
        log = log_create_rec(fname, MSGLEVEL_ALL, window);
        if (log != NULL) log_update(log);
        g_free(fname);
    }

    if (open_log && log != NULL) {
        log_start_logging(log);
        printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_LOG_OPENED, log->fname);
    } else if (close_log && log != NULL && log->handle != -1) {
        log_stop_logging(log);
        printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_LOG_CLOSED, log->fname);
    }

    g_free(params);
}
예제 #5
0
파일: log.c 프로젝트: FabrizioFabbe/silc
static void log_rotate_check(LOG_REC *log)
{
	char *new_fname;

	g_return_if_fail(log != NULL);

	if (log->handle == -1 || log->real_fname == NULL)
		return;

	new_fname = log_filename(log);
	if (strcmp(new_fname, log->real_fname) != 0) {
		/* rotate log */
		log_stop_logging(log);
		signal_emit("log rotated", 1, log);

		log_start_logging(log);
	}
	g_free(new_fname);
}