/[svn]/ircd-hybrid/trunk/src/log.c
ViewVC logotype

Diff of /ircd-hybrid/trunk/src/log.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1830 by michael, Mon Jan 14 17:37:55 2013 UTC revision 1831 by michael, Mon Apr 15 10:57:05 2013 UTC
# Line 38  static struct { Line 38  static struct {
38  } log_type_table[LOG_TYPE_LAST];  } log_type_table[LOG_TYPE_LAST];
39    
40    
41  int  void
42  log_add_file(enum log_type type, size_t size, const char *path)  log_set_file(enum log_type type, size_t size, const char *path)
43  {  {
   if (log_type_table[type].file)  
     fclose(log_type_table[type].file);  
   
44    strlcpy(log_type_table[type].path, path, sizeof(log_type_table[type].path));    strlcpy(log_type_table[type].path, path, sizeof(log_type_table[type].path));
45    log_type_table[type].size = size;    log_type_table[type].size = size;
46    
47    return (log_type_table[type].file = fopen(path, "a")) != NULL;    if (type == LOG_TYPE_IRCD)
48        log_type_table[type].file = fopen(log_type_table[type].path, "a");
49    }
50    
51    void
52    log_del_all(void)
53    {
54      unsigned int type = 0;
55    
56      while (++type < LOG_TYPE_LAST)
57        log_type_table[type].path[0] = '\0';
58  }  }
59    
60  void  void
61  log_close_all(void)  log_reopen_all(void)
62  {  {
63    unsigned int type = 0;    unsigned int type = 0;
64    
65    while (++type < LOG_TYPE_LAST)    while (++type < LOG_TYPE_LAST)
66    {    {
67      if (log_type_table[type].file == NULL)      if (log_type_table[type].file)
68        continue;      {
69          fclose(log_type_table[type].file);
70          log_type_table[type].file = NULL;
71        }
72    
73      fclose(log_type_table[type].file);      if (log_type_table[type].path[0])
74      log_type_table[type].file = NULL;        log_type_table[type].file = fopen(log_type_table[type].path, "a");
75    }    }
76  }  }
77    
# Line 119  ilog(enum log_type type, const char *fmt Line 129  ilog(enum log_type type, const char *fmt
129    unlink(buf);    unlink(buf);
130    rename(log_type_table[type].path, buf);    rename(log_type_table[type].path, buf);
131    
132    log_add_file(type, log_type_table[type].size, log_type_table[type].path);    log_set_file(type, log_type_table[type].size, log_type_table[type].path);
133      log_type_table[type].file = fopen(log_type_table[type].path, "a");
134  }  }

Legend:
Removed from v.1830  
changed lines
  Added in v.1831

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28