Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(2)  |  Call(2)  |  Derive(0)  |  Import(0)
Set up logging for the script, based on the configuration
specified by the 'logging' attribute of the command line
arguments.

:param args: A Namespace object containing a 'logging' attribute
             specifying the name of a logging configuration file
             to use.  If not present or not given, a basic logging
             configuration will be set.

        def _setup_logging(args):
    """
    Set up logging for the script, based on the configuration
    specified by the 'logging' attribute of the command line
    arguments.

    :param args: A Namespace object containing a 'logging' attribute
                 specifying the name of a logging configuration file
                 to use.  If not present or not given, a basic logging
                 configuration will be set.
    """

    log_conf = getattr(args, 'logging', None)
    if log_conf:
        logging.config.fileConfig(log_conf)
    else:
        logging.basicConfig()
        


src/t/u/turnstile-HEAD/tests/unit/test_tools.py   turnstile(Download)
    def test_basic(self, mock_basicConfig, mock_fileConfig):
        tools._setup_logging(argparse.Namespace())
 
        self.assertFalse(mock_fileConfig.called)
        mock_basicConfig.assert_called_once_with()
 
    @mock.patch('logging.config.fileConfig')
    @mock.patch('logging.basicConfig')
    def test_file(self, mock_basicConfig, mock_fileConfig):
        tools._setup_logging(argparse.Namespace(logging='log.conf'))