src/server/daemon/log.c

changeset 443
ef3c8a0e1fee
parent 442
05c2b62448b1
child 490
d218607f5a7e
equal deleted inserted replaced
442:05c2b62448b1 443:ef3c8a0e1fee
104 1, // info 104 1, // info
105 0, // verbose 105 0, // verbose
106 0 // debug 106 0 // debug
107 }; 107 };
108 108
109 int init_logging(void) {
110 log_dup_list = cxPointerLinkedListCreate(cxDefaultAllocator, cx_cmp_ptr);
111 return log_dup_list == NULL;
112 }
113
109 int init_log_file(LogConfig *cfg) { 114 int init_log_file(LogConfig *cfg) {
110 if(is_initialized) { 115 if(is_initialized) {
111 return 0; 116 return 0;
112 } 117 }
113
114 log_dup_list = cxPointerLinkedListCreate(cxDefaultAllocator, cx_cmp_ptr);
115 118
116 /* open the log file */ 119 /* open the log file */
117 mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; 120 mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
118 log_file_fd = open(cfg->file, O_WRONLY | O_CREAT | O_APPEND, mode); 121 log_file_fd = open(cfg->file, O_WRONLY | O_CREAT | O_APPEND, mode);
119 if(log_file_fd == -1) { 122 if(log_file_fd == -1) {
182 185
183 WSBool write_to_stdout = !main_is_daemon(); 186 WSBool write_to_stdout = !main_is_daemon();
184 if(is_initialized) { 187 if(is_initialized) {
185 writev(log_file_fd, io, 2); /* TODO: aio? */ 188 writev(log_file_fd, io, 2); /* TODO: aio? */
186 } else { 189 } else {
187 write_to_stdout = TRUE; 190 //write_to_stdout = TRUE;
188 log_uninitialized_writeln(str, len); 191 log_uninitialized_writeln(str, len);
189 } 192 }
190 193
191 if(write_to_stdout) { 194 if(write_to_stdout) {
192 writev(STDOUT_FILENO, io, 2); 195 writev(STDOUT_FILENO, io, 2);

mercurial