Convert license print statements to logger 19/5819/4
authorThanh Ha <thanh.ha@linuxfoundation.org>
Wed, 9 Aug 2017 22:01:33 +0000 (18:01 -0400)
committerJessica Wagantall <jwagantall@linuxfoundation.org>
Fri, 11 Aug 2017 16:58:28 +0000 (16:58 +0000)
Change-Id: I0597053944aef49b9537fd8d492781fa76c05ad0
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
Signed-off-by: Jeremy Phelps <jphelps@linuxfoundation.org>
lftools/license.py

index 32bb955..52bbf5a 100644 (file)
 __author__ = 'Thanh Ha'
 
 
+import logging
 import os
 import re
 import sys
 
+log = logging.getLogger(__name__)
+
 
 def get_header_text(_file):
     """Scan a file and pulls out the license header.
@@ -53,7 +56,7 @@ def check_license(license_file, code_file):
     code_header = get_header_text(code_file)
 
     if not license_header in code_header:
-        print('ERROR: {} is missing or has incorrect license header.'.format(code_file))
+        log.error('{} is missing or has incorrect license header.'.format(code_file))
         return 1
 
     return 0
@@ -72,4 +75,4 @@ def check_license_directory(license_file, directory, regex=".+\.py$"):
     if missing_license:
         sys.exit(1)
 
-    print('Scan completed did not detect any files missing license headers.')
+    log.info('Scan completed did not detect any files missing license headers.')