summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorLemonBoy <LemonBoy@users.noreply.github.com>2017-07-30 10:06:38 +0200
committerGitHub <noreply@github.com>2017-07-30 10:06:38 +0200
commit663a8e71543787256ba4a58956521a1103be9909 (patch)
treef5880babb5fbfd500107cd8d9c530d2ec4729ef7 /src/core
parent437fbef6eb8f605320841cba119d3abbb3571a75 (diff)
parent2907a82b446d9d0a25157aa4ab560b49853f80d2 (diff)
downloadirssi-663a8e71543787256ba4a58956521a1103be9909.zip
Merge pull request #734 from trasz/master
Don't compute log_dir_create_mode in three different places.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/log.c5
-rw-r--r--src/core/log.h2
-rw-r--r--src/core/rawlog.c18
3 files changed, 12 insertions, 13 deletions
diff --git a/src/core/log.c b/src/core/log.c
index 6af1effc..cee1dab5 100644
--- a/src/core/log.c
+++ b/src/core/log.c
@@ -33,6 +33,8 @@
#define DEFAULT_LOG_FILE_CREATE_MODE 600
GSList *logs;
+int log_file_create_mode;
+int log_dir_create_mode;
static const char *log_item_types[] = {
"target",
@@ -42,8 +44,6 @@ static const char *log_item_types[] = {
};
static char *log_timestamp;
-static int log_file_create_mode;
-static int log_dir_create_mode;
static int rotate_tag;
static int log_item_str2type(const char *type)
@@ -562,7 +562,6 @@ static void read_settings(void)
log_timestamp = g_strdup(settings_get_str("log_timestamp"));
log_file_create_mode = octal2dec(settings_get_int("log_create_mode"));
-
log_dir_create_mode = log_file_create_mode;
if (log_file_create_mode & 0400) log_dir_create_mode |= 0100;
if (log_file_create_mode & 0040) log_dir_create_mode |= 0010;
diff --git a/src/core/log.h b/src/core/log.h
index fae872c7..5a07859b 100644
--- a/src/core/log.h
+++ b/src/core/log.h
@@ -35,6 +35,8 @@ struct _LOG_REC {
};
extern GSList *logs;
+extern int log_file_create_mode;
+extern int log_dir_create_mode;
/* Create log record - you still need to call log_update() to actually add it
into log list */
diff --git a/src/core/rawlog.c b/src/core/rawlog.c
index 5927e730..2ec155fa 100644
--- a/src/core/rawlog.c
+++ b/src/core/rawlog.c
@@ -20,6 +20,7 @@
#include "module.h"
#include "rawlog.h"
+#include "log.h"
#include "modules.h"
#include "signals.h"
#include "commands.h"
@@ -31,8 +32,6 @@
static int rawlog_lines;
static int signal_rawlog;
-static int log_file_create_mode;
-static int log_dir_create_mode;
RAWLOG_REC *rawlog_create(void)
{
@@ -131,8 +130,13 @@ void rawlog_open(RAWLOG_REC *rawlog, const char *fname)
log_file_create_mode);
g_free(path);
+ if (rawlog->handle == -1) {
+ g_warning("rawlog open() failed: %s", strerror(errno));
+ return;
+ }
+
rawlog_dump(rawlog, rawlog->handle);
- rawlog->logging = rawlog->handle != -1;
+ rawlog->logging = TRUE;
}
void rawlog_close(RAWLOG_REC *rawlog)
@@ -140,7 +144,7 @@ void rawlog_close(RAWLOG_REC *rawlog)
if (rawlog->logging) {
write_buffer_flush();
close(rawlog->handle);
- rawlog->logging = 0;
+ rawlog->logging = FALSE;
}
}
@@ -174,12 +178,6 @@ void rawlog_set_size(int lines)
static void read_settings(void)
{
rawlog_set_size(settings_get_int("rawlog_lines"));
- log_file_create_mode = octal2dec(settings_get_int("log_create_mode"));
- log_dir_create_mode = log_file_create_mode;
- if (log_file_create_mode & 0400) log_dir_create_mode |= 0100;
- if (log_file_create_mode & 0040) log_dir_create_mode |= 0010;
- if (log_file_create_mode & 0004) log_dir_create_mode |= 0001;
-
}
static void cmd_rawlog(const char *data, SERVER_REC *server, void *item)