summaryrefslogtreecommitdiff
path: root/other/bootstrap_daemon/src
diff options
context:
space:
mode:
authorMaxim Biro <nurupo.contributions@gmail.com>2015-12-31 20:01:24 -0500
committerMaxim Biro <nurupo.contributions@gmail.com>2015-12-31 20:01:24 -0500
commitffa927fa361c366d8d1d2fefdeb58d0977ab91ae (patch)
tree99cc94fa94a648ab86139c18133cf410fb6298ca /other/bootstrap_daemon/src
parenta40fd1bb6c4769683c11b3e308279c17a0acbc5a (diff)
Rename LOGGER_BACKEND to LOG_BACKEND
Diffstat (limited to 'other/bootstrap_daemon/src')
-rw-r--r--other/bootstrap_daemon/src/log.c12
-rw-r--r--other/bootstrap_daemon/src/log.h10
-rw-r--r--other/bootstrap_daemon/src/tox-bootstrapd.c14
3 files changed, 18 insertions, 18 deletions
diff --git a/other/bootstrap_daemon/src/log.c b/other/bootstrap_daemon/src/log.c
index b5f838fb..f41b8420 100644
--- a/other/bootstrap_daemon/src/log.c
+++ b/other/bootstrap_daemon/src/log.c
@@ -30,15 +30,15 @@
30#include <stdarg.h> 30#include <stdarg.h>
31#include <stdio.h> 31#include <stdio.h>
32 32
33LOGGER_BACKEND current_backend = -1; 33LOG_BACKEND current_backend = -1;
34 34
35bool open_log(LOGGER_BACKEND backend) 35bool open_log(LOG_BACKEND backend)
36{ 36{
37 if (current_backend != -1) { 37 if (current_backend != -1) {
38 return false; 38 return false;
39 } 39 }
40 40
41 if (backend == LOGGER_BACKEND_SYSLOG) { 41 if (backend == LOG_BACKEND_SYSLOG) {
42 openlog(DAEMON_NAME, LOG_NOWAIT | LOG_PID, LOG_DAEMON); 42 openlog(DAEMON_NAME, LOG_NOWAIT | LOG_PID, LOG_DAEMON);
43 } 43 }
44 44
@@ -53,7 +53,7 @@ bool close_log()
53 return false; 53 return false;
54 } 54 }
55 55
56 if (current_backend == LOGGER_BACKEND_SYSLOG) { 56 if (current_backend == LOG_BACKEND_SYSLOG) {
57 closelog(); 57 closelog();
58 } 58 }
59 59
@@ -101,10 +101,10 @@ bool write_log(LOG_LEVEL level, const char *format, ...)
101 va_start(args, format); 101 va_start(args, format);
102 102
103 switch (current_backend) { 103 switch (current_backend) {
104 case LOGGER_BACKEND_SYSLOG: 104 case LOG_BACKEND_SYSLOG:
105 log_syslog(level, format, args); 105 log_syslog(level, format, args);
106 break; 106 break;
107 case LOGGER_BACKEND_STDOUT: 107 case LOG_BACKEND_STDOUT:
108 log_stdout(level, format, args); 108 log_stdout(level, format, args);
109 break; 109 break;
110 } 110 }
diff --git a/other/bootstrap_daemon/src/log.h b/other/bootstrap_daemon/src/log.h
index b97d3733..b7712368 100644
--- a/other/bootstrap_daemon/src/log.h
+++ b/other/bootstrap_daemon/src/log.h
@@ -26,10 +26,10 @@
26 26
27#include <stdbool.h> 27#include <stdbool.h>
28 28
29typedef enum LOGGER_BACKEND { 29typedef enum LOG_BACKEND {
30 LOGGER_BACKEND_SYSLOG, 30 LOG_BACKEND_SYSLOG,
31 LOGGER_BACKEND_STDOUT 31 LOG_BACKEND_STDOUT
32} LOGGER_BACKEND; 32} LOG_BACKEND;
33 33
34typedef enum LOG_LEVEL { 34typedef enum LOG_LEVEL {
35 LOG_LEVEL_INFO, 35 LOG_LEVEL_INFO,
@@ -42,7 +42,7 @@ typedef enum LOG_LEVEL {
42 * @param backend Specifies which backend to use. 42 * @param backend Specifies which backend to use.
43 * @return true on success, flase if log is already opened. 43 * @return true on success, flase if log is already opened.
44 */ 44 */
45bool open_log(LOGGER_BACKEND backend); 45bool open_log(LOG_BACKEND backend);
46 46
47/** 47/**
48 * Releases all used resources by the logger. 48 * Releases all used resources by the logger.
diff --git a/other/bootstrap_daemon/src/tox-bootstrapd.c b/other/bootstrap_daemon/src/tox-bootstrapd.c
index e2bf7ade..3bbddf98 100644
--- a/other/bootstrap_daemon/src/tox-bootstrapd.c
+++ b/other/bootstrap_daemon/src/tox-bootstrapd.c
@@ -544,7 +544,7 @@ bool print_help()
544// Handels command line arguments, setting cfg_file_path and log_backend. 544// Handels command line arguments, setting cfg_file_path and log_backend.
545// Terminates the application if incorrect arguments are specified. 545// Terminates the application if incorrect arguments are specified.
546 546
547void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path, LOGGER_BACKEND *log_backend) 547void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path, LOG_BACKEND *log_backend)
548{ 548{
549 if (argc < 2) { 549 if (argc < 2) {
550 write_log(LOG_LEVEL_ERROR, "Error: No arguments provided.\n\n"); 550 write_log(LOG_LEVEL_ERROR, "Error: No arguments provided.\n\n");
@@ -581,10 +581,10 @@ void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path,
581 581
582 case 'l': 582 case 'l':
583 if (strcmp(optarg, "syslog") == 0) { 583 if (strcmp(optarg, "syslog") == 0) {
584 *log_backend = LOGGER_BACKEND_SYSLOG; 584 *log_backend = LOG_BACKEND_SYSLOG;
585 log_backend_set = true; 585 log_backend_set = true;
586 } else if (strcmp(optarg, "stdout") == 0) { 586 } else if (strcmp(optarg, "stdout") == 0) {
587 *log_backend = LOGGER_BACKEND_STDOUT; 587 *log_backend = LOG_BACKEND_STDOUT;
588 log_backend_set = true; 588 log_backend_set = true;
589 } else { 589 } else {
590 write_log(LOG_LEVEL_ERROR, "Error: Invalid BACKEND value for --log-backend option passed: %s\n\n", optarg); 590 write_log(LOG_LEVEL_ERROR, "Error: Invalid BACKEND value for --log-backend option passed: %s\n\n", optarg);
@@ -610,7 +610,7 @@ void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path,
610 } 610 }
611 611
612 if (!log_backend_set) { 612 if (!log_backend_set) {
613 *log_backend = LOGGER_BACKEND_SYSLOG; 613 *log_backend = LOG_BACKEND_SYSLOG;
614 } 614 }
615 615
616 if (!cfg_file_path_set) { 616 if (!cfg_file_path_set) {
@@ -623,10 +623,10 @@ void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path,
623int main(int argc, char *argv[]) 623int main(int argc, char *argv[])
624{ 624{
625 char *cfg_file_path; 625 char *cfg_file_path;
626 LOGGER_BACKEND log_backend; 626 LOG_BACKEND log_backend;
627 627
628 // choose backend for printing command line argument parsing output based on whether the daemon is being run from a terminal 628 // choose backend for printing command line argument parsing output based on whether the daemon is being run from a terminal
629 log_backend = isatty(STDOUT_FILENO) ? LOGGER_BACKEND_STDOUT : LOGGER_BACKEND_SYSLOG; 629 log_backend = isatty(STDOUT_FILENO) ? LOG_BACKEND_STDOUT : LOG_BACKEND_SYSLOG;
630 630
631 open_log(log_backend); 631 open_log(log_backend);
632 handle_command_line_arguments(argc, argv, &cfg_file_path, &log_backend); 632 handle_command_line_arguments(argc, argv, &cfg_file_path, &log_backend);
@@ -798,7 +798,7 @@ int main(int argc, char *argv[])
798 } 798 }
799 799
800 // Go quiet 800 // Go quiet
801 if (log_backend != LOGGER_BACKEND_STDOUT) { 801 if (log_backend != LOG_BACKEND_STDOUT) {
802 close(STDOUT_FILENO); 802 close(STDOUT_FILENO);
803 close(STDIN_FILENO); 803 close(STDIN_FILENO);
804 close(STDERR_FILENO); 804 close(STDERR_FILENO);