Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Commit

Permalink
fixed bug preventing proper logging ar levels lower than WARNING
Browse files Browse the repository at this point in the history
  • Loading branch information
trstickland committed Aug 14, 2018
1 parent c215fdf commit 70b1933
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions gffmunger/GFFMunger.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,17 @@ def __init__(self,options):

# set up logger
self.logger = logging.getLogger(__name__)
def setLogLevel(level):
self.logger.setLevel(level)
handler = logging.StreamHandler()
handler.setLevel(level)
self.logger.addHandler(handler)
if self.verbose:
self.logger.setLevel(logging.INFO)
self.logger.warning("logging.debug & logging.info seem to be broken at the moment, you'll only see warnings & above :-/")
setLogLevel(logging.INFO)
elif self.quiet:
self.logger.setLevel(logging.CRITICAL)
setLogLevel(logging.CRITICAL)
else:
self.logger.setLevel(logging.WARNING)
setLogLevel(logging.WARNING)

# options from configuration file
config_filename = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', self.config_file)
Expand Down Expand Up @@ -109,9 +113,9 @@ def config_value_is_true(config_value):
if self.output_file:
self.output_file = None
self.logger.debug("Writing output to STDOUT")





def run(self):
try:
# get GFF3 input, stdin or file; sets self.gff3_input_filename
Expand Down Expand Up @@ -234,6 +238,8 @@ def validate_FASTA(self, fasta_filename, silent=False):
Pass path of FASTA file; if valid, True is returned; if invalid, validator STDERR output is printed and False is returned
Validation failure message printed to STDOUT; this can be supressed by passing the optional flag 'silent'"""
self.logger.info("Validating FASTA file "+ fasta_filename)
if self.logger.isEnabledFor(logging.INFO):
print("*** logging INFO ***")
with self.open_text_file(fasta_filename) as handle:
fasta = SeqIO.parse(handle, "fasta")
is_fasta = any(fasta) # False when `fasta` is empty, i.e. wasn't a FASTA file
Expand Down Expand Up @@ -407,6 +413,8 @@ def move_annotations(self):
modified_feature_cache.append(this_polypeptide)

self.logger.info("found "+str(num_polypeptide)+" polypeptide features")
if self.logger.isEnabledFor(logging.INFO):
print("*** logging INFO ***")

self.check_for_anotations(modified_feature_cache)

Expand Down Expand Up @@ -532,6 +540,8 @@ def export_gff3(self):
num_features_written+=1
handle.write( str(this_feature)+"\n" )
self.logger.info("extracted and wrote "+str(num_features_written)+" features from gffutils db")
if self.logger.isEnabledFor(logging.INFO):
print("*** logging INFO ***")

# write fasta
handle.write("##FASTA\n")
Expand Down

0 comments on commit 70b1933

Please sign in to comment.