nodes: 0, module; 1, function_definition; 2, function_name:create_logger; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, expression_statement; 8, comment:# Set up logging; 9, expression_statement; 10, expression_statement; 11, if_statement; 12, expression_statement; 13, expression_statement; 14, comment:# Log to stdout; 15, expression_statement; 16, expression_statement; 17, expression_statement; 18, comment:# Log to file if the option is chosen; 19, if_statement; 20, if_statement; 21, expression_statement; 22, identifier:args; 23, dictionary; 24, comment:"""
          Create and configure the program's logger object.
  
          Log levels:
          DEBUG - Log everything. Hidden unless --debug is used.
          INFO - information only
          ERROR - Critical error
          :param args: Object containing program's parsed command line arguments
          :return: None
          """; 25, assignment; 26, assignment; 27, boolean_operator; 28, block; 29, assignment; 30, assignment; 31, assignment; 32, call; 33, call; 34, boolean_operator; 35, block; 36, boolean_operator; 37, block; 38, assignment; 39, identifier:logger; 40, call; 41, attribute; 42, attribute; 43, comparison_operator:'--debug' in args; 44, comparison_operator:args['--debug'] is True; 45, expression_statement; 46, identifier:file_log_formatter; 47, call; 48, identifier:console_log_formatter; 49, call; 50, identifier:stdout_stream; 51, call; 52, attribute; 53, argument_list; 54, attribute; 55, argument_list; 56, comparison_operator:'--log' in args; 57, comparison_operator:args['--log'] is not None; 58, expression_statement; 59, expression_statement; 60, expression_statement; 61, expression_statement; 62, comparison_operator:'--dry-run' in args; 63, comparison_operator:args['--dry-run'] is True; 64, expression_statement; 65, attribute; 66, identifier:logger; 67, attribute; 68, argument_list; 69, identifier:logger; 70, identifier:level; 71, identifier:logging; 72, identifier:INFO; 73, string; 74, identifier:args; 75, subscript; 76, True; 77, call; 78, attribute; 79, argument_list; 80, attribute; 81, argument_list; 82, attribute; 83, argument_list; 84, identifier:stdout_stream; 85, identifier:setFormatter; 86, identifier:console_log_formatter; 87, identifier:logger; 88, identifier:addHandler; 89, identifier:stdout_stream; 90, string; 91, identifier:args; 92, subscript; 93, None; 94, assignment; 95, assignment; 96, call; 97, call; 98, string; 99, identifier:args; 100, subscript; 101, True; 102, call; 103, identifier:self; 104, identifier:logger; 105, identifier:logging; 106, identifier:getLogger; 107, string:"SmartFileSorter"; 108, string_content:--debug; 109, identifier:args; 110, string; 111, attribute; 112, argument_list; 113, identifier:logging; 114, identifier:Formatter; 115, string; 116, string; 117, identifier:logging; 118, identifier:Formatter; 119, string; 120, identifier:logging; 121, identifier:StreamHandler; 122, keyword_argument; 123, string_content:--log; 124, identifier:args; 125, string; 126, identifier:logfile; 127, call; 128, identifier:logfile_stream; 129, call; 130, attribute; 131, argument_list; 132, attribute; 133, argument_list; 134, string_content:--dry-run; 135, identifier:args; 136, string; 137, attribute; 138, argument_list; 139, string_content:--debug; 140, identifier:logger; 141, identifier:setLevel; 142, attribute; 143, string_content:%(asctime)s %(name)s %(levelname)s %(message)s; 144, string_content:%Y-%m-%d %H:%M:%S; 145, string_content:%(message)s; 146, identifier:stream; 147, attribute; 148, string_content:--log; 149, identifier:open; 150, argument_list; 151, attribute; 152, argument_list; 153, identifier:logfile_stream; 154, identifier:setFormatter; 155, identifier:file_log_formatter; 156, identifier:logger; 157, identifier:addHandler; 158, identifier:logfile_stream; 159, string_content:--dry-run; 160, identifier:logger; 161, identifier:info; 162, string; 163, identifier:logging; 164, identifier:DEBUG; 165, identifier:sys; 166, identifier:stdout; 167, subscript; 168, string; 169, identifier:logging; 170, identifier:StreamHandler; 171, keyword_argument; 172, string_content:Running with --dry-run parameter. Actions will not be performed.; 173, identifier:args; 174, string; 175, string_content:w; 176, identifier:stream; 177, identifier:logfile; 178, string_content:--log
code: def create_logger(self, args={}):
          """
          Create and configure the program's logger object.
  
          Log levels:
          DEBUG - Log everything. Hidden unless --debug is used.
          INFO - information only
          ERROR - Critical error
          :param args: Object containing program's parsed command line arguments
          :return: None
          """
          # Set up logging
          logger = logging.getLogger("SmartFileSorter")
          logger.level = logging.INFO
  
          if '--debug' in args and args['--debug'] is True:
              logger.setLevel(logging.DEBUG)
  
          file_log_formatter = logging.Formatter('%(asctime)s %(name)s %(levelname)s %(message)s',
                                                 '%Y-%m-%d %H:%M:%S')
          console_log_formatter = logging.Formatter('%(message)s')
  
          # Log to stdout
          stdout_stream = logging.StreamHandler(stream=sys.stdout)
          stdout_stream.setFormatter(console_log_formatter)
          logger.addHandler(stdout_stream)
  
          # Log to file if the option is chosen
          if '--log' in args and args['--log'] is not None:
              logfile = open(args['--log'], 'w')
              logfile_stream = logging.StreamHandler(stream=logfile)
              logfile_stream.setFormatter(file_log_formatter)
              logger.addHandler(logfile_stream)
  
          if '--dry-run' in args and args['--dry-run'] is True:
              logger.info('Running with --dry-run parameter. Actions will not be performed.')
          self.logger = logger