forked from enlightenment/efl
efreetd - only open log file is env var is set to do so
set EFREETD_LOG to something to get efreetd to log. otherwise efretd log files can end up rather larth and since they go in xdg_runtimedir - thats mostly a ramdisk... they eat actual ram. so save a lot of memory and only log if asked to. @fix
This commit is contained in:
parent
a739d4d7da
commit
4a2f14638f
|
@ -8,6 +8,9 @@
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include <Ecore.h>
|
#include <Ecore.h>
|
||||||
#include <Ecore_File.h>
|
#include <Ecore_File.h>
|
||||||
|
@ -55,13 +58,20 @@ main(int argc, char *argv[])
|
||||||
hostname_str = "";
|
hostname_str = "";
|
||||||
else
|
else
|
||||||
hostname_str = buf;
|
hostname_str = buf;
|
||||||
snprintf(path, sizeof(path), "%s/efreetd_%s_XXXXXX.log",
|
if (getenv("EFREETD_LOG"))
|
||||||
log_file_dir, hostname_str);
|
|
||||||
fd = eina_file_mkstemp(path, NULL);
|
|
||||||
if (fd < 0)
|
|
||||||
{
|
{
|
||||||
ERR("Can't create log file '%s'\b", path);;
|
snprintf(path, sizeof(path), "%s/efreetd_%s_XXXXXX.log",
|
||||||
goto tmp_error;
|
log_file_dir, hostname_str);
|
||||||
|
fd = eina_file_mkstemp(path, NULL);
|
||||||
|
if (fd < 0)
|
||||||
|
{
|
||||||
|
ERR("Can't create log file '%s'\b", path);;
|
||||||
|
goto tmp_error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fd = open("/dev/null", O_WRONLY);
|
||||||
}
|
}
|
||||||
log = fdopen(fd, "wb");
|
log = fdopen(fd, "wb");
|
||||||
if (!log) goto tmp_error;
|
if (!log) goto tmp_error;
|
||||||
|
|
Loading…
Reference in New Issue