diff options
author | ben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2002-06-15 20:03:46 +0000 |
---|---|---|
committer | ben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2002-06-15 20:03:46 +0000 |
commit | 127e5a48e7b64b5aa7c01b4ccfcc6852f31c2b20 (patch) | |
tree | 94a60eb3e0b5fdbe490b2d67e81a35b2fa04c0ed /rdiff-backup/rdiff_backup/log.py | |
parent | d2943df4a4eb71162dfd3939e0c668a83d85ee4e (diff) | |
download | rdiff-backup-127e5a48e7b64b5aa7c01b4ccfcc6852f31c2b20.tar.gz |
Various CPU optimizations
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@126 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/rdiff_backup/log.py')
-rw-r--r-- | rdiff-backup/rdiff_backup/log.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/rdiff-backup/rdiff_backup/log.py b/rdiff-backup/rdiff_backup/log.py index 3b9c08a..6b4ba06 100644 --- a/rdiff-backup/rdiff_backup/log.py +++ b/rdiff-backup/rdiff_backup/log.py @@ -81,7 +81,21 @@ class Logger: message) def __call__(self, message, verbosity): - """Log message that has verbosity importance""" + """Log message that has verbosity importance + + message can be a string, which is logged as-is, or a function, + which is then called and should return the string to be + logged. We do it this way in case producing the string would + take a significant amount of CPU. + + """ + if verbosity > self.verbosity and verbosity > self.term_verbosity: + return + + if not type(message) is types.StringType: + assert type(message) is types.FunctionType + message = message() + if verbosity <= self.verbosity: self.log_to_file(message) if verbosity <= self.term_verbosity: self.log_to_term(message, verbosity) |