Bug 1455143 - Use a global logger instance; r=ted
authorGregory Szorc <gps@mozilla.com>
Wed, 18 Apr 2018 15:33:31 -0700
changeset 785569 e6d309fde362cef30e20aba408958cbce3884425
parent 785568 37fec60424380f4a64d2f568d644e26679a2f99f
child 785570 2bbe78c011d3a4631a3a34b47811564463ab66e5
push id107257
push userdgottwald@mozilla.com
push dateFri, 20 Apr 2018 10:55:57 +0000
Bug 1455143 - Use a global logger instance; r=ted MozReview-Commit-ID: 1RyLZBMx6mH
--- 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>
         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"' %
         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
         loglevel = logging.INFO
     # Set up logging
-    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: