diff --git a/Makefile b/Makefile index ce98e08..4d30753 100644 --- a/Makefile +++ b/Makefile @@ -116,6 +116,9 @@ install: install -m 755 -d $(DESTDIR)/etc/tune-profiles cp -a tune-profiles/* $(DESTDIR)/etc/tune-profiles + # Create log directory + mkdir -p $(DESTDIR)/var/log/tuned + changelog: git log > ChangeLog diff --git a/tuned.spec b/tuned.spec index 8135765..76c63af 100644 --- a/tuned.spec +++ b/tuned.spec @@ -90,6 +90,7 @@ fi %config(noreplace) %attr(0644,root,root) %{_sysconfdir}/sysconfig/ktune %config(noreplace) %attr(0644,root,root) %{_sysconfdir}/sysctl.ktune %dir %attr(0755,root,root) %{_sysconfdir}/ktune.d +%dir /var/log/tuned %files utils %defattr(-,root,root,-) diff --git a/tuned_logging.py b/tuned_logging.py index 1a53ba6..abc25ed 100644 --- a/tuned_logging.py +++ b/tuned_logging.py @@ -16,9 +16,12 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # +import os, os.path import logging import logging.handlers +LOG_FILENAME="/var/log/tuned/tuned.log" + class TunedLogger (logging.getLoggerClass()): def setLevelString(self, name): @@ -46,7 +49,12 @@ tuned_logger.setLevel(logging.INFO) formatter = logging.Formatter("%(asctime)s %(levelname)-8s %(name)s: %(message)s") console_handler = logging.StreamHandler() -file_handler = logging.handlers.RotatingFileHandler("/var/log/tuned.log", maxBytes=200*1000, backupCount=2) + +log_directory = os.path.dirname(LOG_FILENAME) +if not os.path.exists(log_directory): + os.makedirs(log_directory) + +file_handler = logging.handlers.RotatingFileHandler(LOG_FILENAME, maxBytes=200*1000, backupCount=2) console_handler.setFormatter(formatter) file_handler.setFormatter(formatter)