diff options
| author | Joel Andres Granados <jgranado@redhat.com> | 2008-07-11 13:47:23 +0200 |
|---|---|---|
| committer | Joel Andres Granados <jgranado@redhat.com> | 2008-07-11 15:33:43 +0200 |
| commit | c5c3e6cae831bd2d88358bcb1df63f6bab3c66e6 (patch) | |
| tree | 8296749e2a916eb92a740bab76c718f6ea735e1e | |
| parent | bbd61c151a520ae155ca06ddc351d7276564b8e1 (diff) | |
Handle the situation where /var/log/ directory is not present.
| -rwxr-xr-x | firstaidkit | 22 | ||||
| -rw-r--r-- | pyfirstaidkit/configuration.py | 1 |
2 files changed, 13 insertions, 10 deletions
diff --git a/firstaidkit b/firstaidkit index f7ac42a..3887979 100755 --- a/firstaidkit +++ b/firstaidkit @@ -234,17 +234,19 @@ if __name__=="__main__": sys.exit(1) # initialize log for plugin system. - try: - initLogger(Config) - except IOError, ioe: - if ioe[0] == 13: - #This is probably because the user is not root. - Config.log.filename = "firstaidkit.log" + fallbacks = Config.log.fallbacks.split(",") + for lfile in fallbacks: + try: initLogger(Config) - else: - print ioe - usage(sys.argv[0]) - sys.exit(1) + break + except Exception, e: + if lfile != fallbacks[len(fallbacks)-1]: + Config.log.filename = lfile + continue + else: + print e + usage(sys.argv[0]) + sys.exit(1) report = reporting.Reports(maxsize = 1, round = True) try: diff --git a/pyfirstaidkit/configuration.py b/pyfirstaidkit/configuration.py index bf337a3..feb0b46 100644 --- a/pyfirstaidkit/configuration.py +++ b/pyfirstaidkit/configuration.py @@ -39,6 +39,7 @@ def createDefaultConfig(config): config.operation.printinfo = "False" config.log.method = "file" config.log.filename = "/var/log/firstaidkit.log" + config.log.fallbacks = "firstaidkit.log,/tmp/firstaidkit.log,/dev/null" config.plugin.disabled = "" config.backup.method = "file" config.backup.path = "/tmp/firstaidkitbackup" |
