aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-07-02 15:00:09 +0200
committerMichael Vetter <jubalh@iodoru.org>2020-07-02 15:00:09 +0200
commitf8ff93234eb118de2e69d0c4667a6cbbe90e8f8c (patch)
treeab04e9c4eda2ffb0874b6ad37a4c2e32a0b10326 /src
parentf4159d8168fa7fc1e358066d288dbf94137a8628 (diff)
downloadprofani-tty-f8ff93234eb118de2e69d0c4667a6cbbe90e8f8c.tar.gz
log.c: Use gchar* instead of GString for mainlogfile
Diffstat (limited to 'src')
-rw-r--r--src/log.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/log.c b/src/log.c
index d246e014..56ebfec1 100644
--- a/src/log.c
+++ b/src/log.c
@@ -55,7 +55,7 @@
#define PROF "prof"
static FILE *logp;
-GString *mainlogfile = NULL;
+static gchar *mainlogfile = NULL;
static GTimeZone *tz;
static GDateTime *dt;
@@ -148,20 +148,19 @@ log_init(log_level_t filter, char *log_file)
{
level_filter = filter;
tz = g_time_zone_new_local();
-
- gchar *lf;
- lf = files_get_log_file(log_file);
+ gchar *lf = files_get_log_file(log_file);
logp = fopen(lf, "a");
g_chmod(lf, S_IRUSR | S_IWUSR);
- mainlogfile = g_string_new(lf);
+ mainlogfile = g_strdup(lf);
+
g_free(lf);
}
void
log_reinit(void)
{
- char *lf = strdup(mainlogfile->str);
+ char *lf = strdup(mainlogfile);
char *start = strrchr(lf, '/') +1;
char *end = strstr(start, ".log");
*end = '\0';
@@ -175,7 +174,7 @@ log_reinit(void)
const char*
get_log_file_location(void)
{
- return mainlogfile->str;
+ return mainlogfile;
}
log_level_t
@@ -187,7 +186,7 @@ log_get_filter(void)
void
log_close(void)
{
- g_string_free(mainlogfile, TRUE);
+ g_free(mainlogfile);
mainlogfile = NULL;
g_time_zone_unref(tz);
if (logp) {
@@ -240,7 +239,7 @@ log_level_from_string(char *log_level)
static void
_rotate_log_file(void)
{
- gchar *log_file = strdup(mainlogfile->str);
+ gchar *log_file = g_strdup(mainlogfile);
size_t len = strlen(log_file);
gchar *log_file_new = malloc(len + 4);
int i = 1;
@@ -252,7 +251,7 @@ _rotate_log_file(void)
break;
}
- char *lf = strdup(mainlogfile->str);
+ char *lf = strdup(mainlogfile);
char *start = strrchr(lf, '/') +1;
char *end = strstr(start, ".log");
*end = '\0';