Add a EMERGE_LOG_DIR variable to control the location of emerge.log and
authorZac Medico <zmedico@gentoo.org>
Thu, 18 Jun 2009 19:55:17 +0000 (19:55 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 18 Jun 2009 19:55:17 +0000 (19:55 -0000)
emerge-fetch.log. This was requested by Eitan Mosenkis <eitan@mosenkis.net>
for use in his 'online image builder' soc project.

svn path=/main/trunk/; revision=13652

man/make.conf.5
pym/_emerge/__init__.py
pym/portage/__init__.py

index ef5913a8539bf55dc9b7cea1a7b4add8a2f7e664..2b5a7645f470bb1ff84589e97a2acdf658b6b1f9 100644 (file)
@@ -130,6 +130,11 @@ Options to append to the end of the \fBemerge\fR(1) command line on every invoca
 These options will not be appended to the command line if \-\-ignore\-default\-opts
 is specified.
 .TP
+.B EMERGE_LOG_DIR
+Controls the location of emerge.log and emerge-fetch.log.
+.br
+Defaults to /var/log.
+.TP
 .B EPAUSE_IGNORE
 Defines whether or not to ignore short pauses that occur when displaying
 important informational messages.  This variable is unset by default.
index 8ef667a0791aaa40bd2820db8083184ce7163a8a..a3921b629fe43d2ec3a4313970a59b49aebd149f 100644 (file)
@@ -238,13 +238,15 @@ shortmapping={
 "v":"--verbose",   "V":"--version"
 }
 
+_emerge_log_dir = '/var/log'
+
 def emergelog(xterm_titles, mystr, short_msg=None):
        if xterm_titles and short_msg:
                if "HOSTNAME" in os.environ:
                        short_msg = os.environ["HOSTNAME"]+": "+short_msg
                xtermTitle(short_msg)
        try:
-               file_path = "/var/log/emerge.log"
+               file_path = os.path.join(_emerge_log_dir, 'emerge.log')
                mylogfile = open(file_path, "a")
                portage.util.apply_secpass_permissions(file_path,
                        uid=portage.portage_uid, gid=portage.portage_gid,
@@ -10137,7 +10139,7 @@ class Scheduler(PollScheduler):
        _bad_resume_opts = set(["--ask", "--changelog",
                "--resume", "--skipfirst"])
 
-       _fetch_log = "/var/log/emerge-fetch.log"
+       _fetch_log = os.path.join(_emerge_log_dir, 'emerge-fetch.log')
 
        class _iface_class(SlotObject):
                __slots__ = ("dblinkEbuildPhase", "dblinkDisplayMerge",
@@ -16181,6 +16183,20 @@ def emerge_main():
                def emergelog(*pargs, **kargs):
                        pass
 
+       else:
+               if 'EMERGE_LOG_DIR' in settings:
+                       try:
+                               # At least the parent needs to exist for the lock file.
+                               portage.util.ensure_dirs(settings['EMERGE_LOG_DIR'])
+                       except portage.exception.PortageException, e:
+                               writemsg_level("!!! Error creating directory for " + \
+                                       "EMERGE_LOG_DIR='%s':\n!!! %s\n" % \
+                                       (settings['EMERGE_LOG_DIR'], e),
+                                       noiselevel=-1, level=logging.ERROR)
+                       else:
+                               global _emerge_log_dir
+                               _emerge_log_dir = settings['EMERGE_LOG_DIR']
+
        if not "--pretend" in myopts:
                emergelog(xterm_titles, "Started emerge on: "+\
                        time.strftime("%b %d, %Y %H:%M:%S", time.localtime()))
index cd8adbba4251a8540a95add30078da3abda40874..575e75c4b300021ee2c4aa86e81553377d73b1fd 100644 (file)
@@ -1135,6 +1135,7 @@ class config(object):
                "ACCEPT_KEYWORDS", "AUTOCLEAN",
                "CLEAN_DELAY", "COLLISION_IGNORE", "CONFIG_PROTECT",
                "CONFIG_PROTECT_MASK", "EGENCACHE_DEFAULT_OPTS", "EMERGE_DEFAULT_OPTS",
+               "EMERGE_LOG_DIR",
                "EMERGE_WARNING_DELAY", "FETCHCOMMAND", "FETCHCOMMAND_FTP",
                "FETCHCOMMAND_HTTP", "FETCHCOMMAND_SFTP",
                "GENTOO_MIRRORS", "NOCONFMEM", "O",