Bug 1455143 - Use a global logger instance; r?Build draft
authorGregory Szorc <gps@mozilla.com>
Wed, 18 Apr 2018 15:33:31 -0700
changeset 785299 feb1ba3bbe0f5cb05925f176f0b191df5a7e9114
parent 785298 9f0b34908530f0afe00bd10cd490471ee4f41481
child 785300 3bf7ce7764b4aaa32a9ddd01be70452664f63493
push id107184
push userbmo:gps@mozilla.com
push dateThu, 19 Apr 2018 21:22:59 +0000
reviewersBuild
bugs1455143
milestone61.0a1
Bug 1455143 - Use a global logger instance; r?Build MozReview-Commit-ID: 1RyLZBMx6mH
build/checksums.py
--- a/build/checksums.py
+++ b/build/checksums.py
@@ -5,27 +5,27 @@
 
 from __future__ import with_statement
 
 from optparse import OptionParser
 import hashlib
 import logging
 import os
 
+logger = logging.getLogger('checksums.py')
 
 def digest_file(filename, digest, chunk_size=1024):
     '''Produce a checksum for the file specified by 'filename'.  'filename'
     is a string path to a file that is opened and read in this function.  The
     checksum algorithm is specified by 'digest' and is a valid OpenSSL
     algorithm.  If the digest used is not valid or Python's hashlib doesn't
     work, the None object will be returned instead.  The size of blocks
     that this function will read from the file object it opens based on
     'filename' can be specified by 'chunk_size', which defaults to 1K'''
     assert not os.path.isdir(filename), 'this function only works with files'
-    logger = logging.getLogger('checksums.py')
 
     logger.debug('Creating new %s object' % digest)
     h = hashlib.new(digest)
     with open(filename, 'rb') as f:
         while True:
             data = f.read(chunk_size)
             if not data:
                 logger.debug('Finished reading in file')
@@ -47,17 +47,16 @@ def process_files(files, output_filename
     and needs to be a list of valid OpenSSL algorithms.
 
     The output file is written in the format:
         <hash> <algorithm> <filesize> <filepath>
     Example:
         d1fa09a<snip>e4220 sha1 14250744 firefox-4.0b6pre.en-US.mac64.dmg
     '''
 
-    logger = logging.getLogger('checksums.py')
     if os.path.exists(output_filename):
         logger.debug('Overwriting existing checksums file "%s"' %
                      output_filename)
     else:
         logger.debug('Creating a new checksums file "%s"' % output_filename)
     with open(output_filename, 'w+') as output:
         for file in files:
             if os.path.isdir(file):
@@ -122,17 +121,16 @@ def main():
         loglevel = logging.DEBUG
     elif options.quiet:
         loglevel = logging.ERROR
     else:
         loglevel = logging.INFO
 
     # Set up logging
     setup_logging(loglevel)
-    logger = logging.getLogger('checksums.py')
 
     # Validate the digest type to use
     if not options.digests:
         options.digests = ['sha1']
 
     # Validate the files to checksum
     files = []
     for i in args: