logging: log file moved into separate directory
This commit is contained in:
parent
ed3e42d48f
commit
951aaba78d
3 changed files with 13 additions and 1 deletions
3
Makefile
3
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
|
||||
|
||||
|
|
|
|||
|
|
@ -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,-)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue