X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Flogfile.c;h=102f12b3a9b7589a5d340fadc6f1ef43e89ae888;hb=1a7050de376608268d11293d4e5faa3fb8516c5a;hp=fed0a75ebc154bcb96598e077b7588e58fa83c9d;hpb=1edbe3e599e3318f89e0ee57d83640c7d02f9079;p=collectd.git diff --git a/src/logfile.c b/src/logfile.c index fed0a75e..102f12b3 100644 --- a/src/logfile.c +++ b/src/logfile.c @@ -1,5 +1,5 @@ /** - * collectd - src/stderr.c + * collectd - src/logfile.c * Copyright (C) 2007 Sebastian Harl * * This program is free software; you can redistribute it and/or modify it @@ -43,7 +43,7 @@ static const char *config_keys[] = }; static int config_keys_num = STATIC_ARRAY_SIZE (config_keys); -static int stderr_config (const char *key, const char *value) +static int logfile_config (const char *key, const char *value) { if (0 == strcasecmp (key, "LogLevel")) { if ((0 == strcasecmp (value, "emerg")) @@ -66,24 +66,15 @@ static int stderr_config (const char *key, const char *value) } else if (0 == strcasecmp (key, "File")) { sfree (log_file); - - if (access (value, W_OK) == 0) - log_file = strdup (value); - else { - char errbuf[1024]; - /* We can't use `ERROR' yet.. */ - fprintf (stderr, "stderr plugin: Access to %s denied: %s\n", - value, sstrerror (errno, errbuf, sizeof (errbuf))); - return 1; - } + log_file = strdup (value); } else { return -1; } return 0; -} /* int stderr_config (const char *, const char *) */ +} /* int logfile_config (const char *, const char *) */ -static void stderr_log (int severity, const char *msg) +static void logfile_log (int severity, const char *msg) { FILE *fh; int do_close = 0; @@ -106,7 +97,7 @@ static void stderr_log (int severity, const char *msg) if (fh == NULL) { char errbuf[1024]; - fprintf (stderr, "stderr plugin: fopen (%s) failed: %s\n", + fprintf (stderr, "logfile plugin: fopen (%s) failed: %s\n", (log_file == NULL) ? "" : log_file, sstrerror (errno, errbuf, sizeof (errbuf))); } @@ -120,14 +111,13 @@ static void stderr_log (int severity, const char *msg) pthread_mutex_unlock (&file_lock); return; -} /* void stderr_log (int, const char *) */ +} /* void logfile_log (int, const char *) */ void module_register (void) { - plugin_register_config ("stderr", stderr_config, + plugin_register_config ("logfile", logfile_config, config_keys, config_keys_num); - plugin_register_log ("stderr", stderr_log); - return; + plugin_register_log ("logfile", logfile_log); } /* void module_register (void) */ /* vim: set sw=4 ts=4 tw=78 noexpandtab : */