import logging
import sys

from tagversion.argparse import ArgumentParser
from tagversion.git import GitVersion
from tagversion.write import WriteFile


def main():
    logging.basicConfig(level=logging.WARNING)

    parser = ArgumentParser()
    subcommand = parser.add_subparsers(dest='subcommand')

    GitVersion.setup_subparser(subcommand)
    WriteFile.setup_subparser(subcommand)

    args = parser.parse_args(default_subparser='version')

    command = args.cls(args)
    sys.exit(command.run())

import logging
import os
import sys

from tagversion.argparse import ArgumentParser
from tagversion.git import GitVersion
from tagversion.write import WriteFile

LOG_LEVEL = os.environ.get('LOG_LEVEL', 'warning')


def main():
    logging.basicConfig(level=getattr(logging, LOG_LEVEL.upper()))

    parser = ArgumentParser()
    subcommand = parser.add_subparsers(dest='subcommand')

    GitVersion.setup_subparser(subcommand)
    WriteFile.setup_subparser(subcommand)

    args = parser.parse_args(default_subparser='version')

    command = args.cls(args)
    sys.exit(command.run())

Allow log level to be changed via environment variable
Allow log level to be changed via environment variable

  import logging
+ import os
  import sys
  
  from tagversion.argparse import ArgumentParser
  from tagversion.git import GitVersion
  from tagversion.write import WriteFile
  
+ LOG_LEVEL = os.environ.get('LOG_LEVEL', 'warning')
+ 
  
  def main():
-     logging.basicConfig(level=logging.WARNING)
+     logging.basicConfig(level=getattr(logging, LOG_LEVEL.upper()))
  
      parser = ArgumentParser()
      subcommand = parser.add_subparsers(dest='subcommand')
  
      GitVersion.setup_subparser(subcommand)
      WriteFile.setup_subparser(subcommand)
  
      args = parser.parse_args(default_subparser='version')
  
      command = args.cls(args)
      sys.exit(command.run())
  
Allow log level to be changed via environment variable
## Code Before:
import logging
import sys

from tagversion.argparse import ArgumentParser
from tagversion.git import GitVersion
from tagversion.write import WriteFile


def main():
    logging.basicConfig(level=logging.WARNING)

    parser = ArgumentParser()
    subcommand = parser.add_subparsers(dest='subcommand')

    GitVersion.setup_subparser(subcommand)
    WriteFile.setup_subparser(subcommand)

    args = parser.parse_args(default_subparser='version')

    command = args.cls(args)
    sys.exit(command.run())

## Instruction:
Allow log level to be changed via environment variable
## Code After:
import logging
import os
import sys

from tagversion.argparse import ArgumentParser
from tagversion.git import GitVersion
from tagversion.write import WriteFile

LOG_LEVEL = os.environ.get('LOG_LEVEL', 'warning')


def main():
    logging.basicConfig(level=getattr(logging, LOG_LEVEL.upper()))

    parser = ArgumentParser()
    subcommand = parser.add_subparsers(dest='subcommand')

    GitVersion.setup_subparser(subcommand)
    WriteFile.setup_subparser(subcommand)

    args = parser.parse_args(default_subparser='version')

    command = args.cls(args)
    sys.exit(command.run())
