How to use the dtale.cli.clickutils.setup_logging function in dtale

To help you get started, we’ve selected a few dtale examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github man-group / dtale / tests / dtale / test_clickutils.py View on Github external
stack.enter_context(mock.patch('socket.gethostname', mock.Mock(return_value='test')))
        mock_linf = stack.enter_context(mock.patch('logging.info', mock.Mock()))
        stack.enter_context(mock.patch('logging.getLogger', mock.Mock()))
        setup_logging(None, None)
        mock_fh.assert_not_called()
        mock_lbc.has_call(mock.call(format="%(asctime)s - %(levelname)-8s - %(message)s", level=logging.INFO))
        mock_linf.has_call(mock.call('test'))
        mock_linf.has_call(mock.call('Hostname: test'))

    with ExitStack() as stack:
        mock_fh = stack.enter_context(mock.patch('logging.FileHandler', mock.Mock()))
        mock_lbc = stack.enter_context(mock.patch('logging.basicConfig', mock.Mock()))
        stack.enter_context(mock.patch('logging.getLogger', mock.Mock()))
        stack.enter_context(mock.patch('sys.argv', ['test']))
        stack.enter_context(mock.patch('socket.gethostname', mock.Mock(return_value='test')))
        setup_logging('test_log', None, verbose=True)
        mock_fh.assert_called_once()
        mock_lbc.has_call(mock.call(format="%(asctime)s - %(levelname)-8s - %(message)s", level=logging.DEBUG))

        for level in ['debug', 'info', 'warning', 'error', 'critical'][::-1]:
            setup_logging(None, level)
            mock_lbc.has_call(
                mock.call(format="%(asctime)s - %(levelname)-8s - %(message)s", level=getattr(logging, level.upper()))
            )

    with ExitStack() as stack:
        mock_fh = stack.enter_context(mock.patch('logging.FileHandler', mock.Mock()))
        mock_lbc = stack.enter_context(mock.patch('logging.basicConfig', mock.Mock()))
        stack.enter_context(mock.patch('logging.getLogger', mock.Mock()))
        stack.enter_context(mock.patch('sys.argv', ['test']))
        stack.enter_context(mock.patch('socket.gethostname', mock.Mock(side_effect=Exception('hostname exception'))))
        mock_linf = stack.enter_context(mock.patch('logging.info', mock.Mock()))
github man-group / dtale / tests / dtale / test_clickutils.py View on Github external
mock_lbc.has_call(mock.call(format="%(asctime)s - %(levelname)-8s - %(message)s", level=logging.DEBUG))

        for level in ['debug', 'info', 'warning', 'error', 'critical'][::-1]:
            setup_logging(None, level)
            mock_lbc.has_call(
                mock.call(format="%(asctime)s - %(levelname)-8s - %(message)s", level=getattr(logging, level.upper()))
            )

    with ExitStack() as stack:
        mock_fh = stack.enter_context(mock.patch('logging.FileHandler', mock.Mock()))
        mock_lbc = stack.enter_context(mock.patch('logging.basicConfig', mock.Mock()))
        stack.enter_context(mock.patch('logging.getLogger', mock.Mock()))
        stack.enter_context(mock.patch('sys.argv', ['test']))
        stack.enter_context(mock.patch('socket.gethostname', mock.Mock(side_effect=Exception('hostname exception'))))
        mock_linf = stack.enter_context(mock.patch('logging.info', mock.Mock()))
        setup_logging(None, None, verbose=True)
        mock_fh.assert_not_called()
        mock_lbc.has_call(mock.call(format="%(asctime)s - %(levelname)-8s - %(message)s", level=logging.DEBUG))
        mock_linf.has_call(mock.call('hostname exception'))
github man-group / dtale / tests / dtale / test_clickutils.py View on Github external
mock_lbc.has_call(mock.call(format="%(asctime)s - %(levelname)-8s - %(message)s", level=logging.INFO))
        mock_linf.has_call(mock.call('test'))
        mock_linf.has_call(mock.call('Hostname: test'))

    with ExitStack() as stack:
        mock_fh = stack.enter_context(mock.patch('logging.FileHandler', mock.Mock()))
        mock_lbc = stack.enter_context(mock.patch('logging.basicConfig', mock.Mock()))
        stack.enter_context(mock.patch('logging.getLogger', mock.Mock()))
        stack.enter_context(mock.patch('sys.argv', ['test']))
        stack.enter_context(mock.patch('socket.gethostname', mock.Mock(return_value='test')))
        setup_logging('test_log', None, verbose=True)
        mock_fh.assert_called_once()
        mock_lbc.has_call(mock.call(format="%(asctime)s - %(levelname)-8s - %(message)s", level=logging.DEBUG))

        for level in ['debug', 'info', 'warning', 'error', 'critical'][::-1]:
            setup_logging(None, level)
            mock_lbc.has_call(
                mock.call(format="%(asctime)s - %(levelname)-8s - %(message)s", level=getattr(logging, level.upper()))
            )

    with ExitStack() as stack:
        mock_fh = stack.enter_context(mock.patch('logging.FileHandler', mock.Mock()))
        mock_lbc = stack.enter_context(mock.patch('logging.basicConfig', mock.Mock()))
        stack.enter_context(mock.patch('logging.getLogger', mock.Mock()))
        stack.enter_context(mock.patch('sys.argv', ['test']))
        stack.enter_context(mock.patch('socket.gethostname', mock.Mock(side_effect=Exception('hostname exception'))))
        mock_linf = stack.enter_context(mock.patch('logging.info', mock.Mock()))
        setup_logging(None, None, verbose=True)
        mock_fh.assert_not_called()
        mock_lbc.has_call(mock.call(format="%(asctime)s - %(levelname)-8s - %(message)s", level=logging.DEBUG))
        mock_linf.has_call(mock.call('hostname exception'))
github man-group / dtale / tests / dtale / test_clickutils.py View on Github external
def test_setup_logging():

    with ExitStack() as stack:
        mock_fh = stack.enter_context(mock.patch('logging.FileHandler', mock.Mock()))
        mock_lbc = stack.enter_context(mock.patch('logging.basicConfig', mock.Mock()))
        stack.enter_context(mock.patch('sys.argv', ['test']))
        stack.enter_context(mock.patch('socket.gethostname', mock.Mock(return_value='test')))
        mock_linf = stack.enter_context(mock.patch('logging.info', mock.Mock()))
        stack.enter_context(mock.patch('logging.getLogger', mock.Mock()))
        setup_logging(None, None)
        mock_fh.assert_not_called()
        mock_lbc.has_call(mock.call(format="%(asctime)s - %(levelname)-8s - %(message)s", level=logging.INFO))
        mock_linf.has_call(mock.call('test'))
        mock_linf.has_call(mock.call('Hostname: test'))

    with ExitStack() as stack:
        mock_fh = stack.enter_context(mock.patch('logging.FileHandler', mock.Mock()))
        mock_lbc = stack.enter_context(mock.patch('logging.basicConfig', mock.Mock()))
        stack.enter_context(mock.patch('logging.getLogger', mock.Mock()))
        stack.enter_context(mock.patch('sys.argv', ['test']))
        stack.enter_context(mock.patch('socket.gethostname', mock.Mock(return_value='test')))
        setup_logging('test_log', None, verbose=True)
        mock_fh.assert_called_once()
        mock_lbc.has_call(mock.call(format="%(asctime)s - %(levelname)-8s - %(message)s", level=logging.DEBUG))

        for level in ['debug', 'info', 'warning', 'error', 'critical'][::-1]:
github man-group / dtale / dtale / app.py View on Github external
other process running at that location
    :type force: bool, optional

    :Example:

        >>> import dtale
        >>> import pandas as pd
        >>> df = pandas.DataFrame([dict(a=1,b=2,c=3)])
        >>> dtale.show(df)
        D-Tale started at: http://hostname:port

        ..link displayed in logging can be copied and pasted into any browser
    """

    logfile, log_level, verbose = map(kwargs.get, ['logfile', 'log_level', 'verbose'])
    setup_logging(logfile, log_level or 'info', verbose)

    initialize_process_props(host, port, force)
    url = build_url(ACTIVE_PORT, ACTIVE_HOST)
    instance = startup(url, data=data, data_loader=data_loader, name=name)
    is_active = not running_with_flask_debug() and is_up(url)
    if is_active:
        def _start():
            if open_browser:
                instance.open_browser()
    else:
        def _start():
            app = build_app(url, reaper_on=reaper_on, host=ACTIVE_HOST)
            if debug:
                app.jinja_env.auto_reload = True
                app.config['TEMPLATES_AUTO_RELOAD'] = True
            else:
github man-group / dtale / dtale / cli / script.py View on Github external
def main(host=None, port=None, debug=False, no_reaper=False, open_browser=False, name=None, **kwargs):
    """
    Runs a local server for the D-Tale application.

    This local server is recommended when you have a pandas object stored in a CSV
    or retrievable from :class:`arctic.Arctic` data store.
    """
    log_opts = get_log_options(kwargs)
    setup_logging(log_opts.get('logfile'), log_opts.get('log_level'), log_opts.get('verbose'))

    data_loader = check_loaders(kwargs)

    show(host=host, port=int(port or find_free_port()), debug=debug, subprocess=False, data_loader=data_loader,
         reaper_on=not no_reaper, open_browser=open_browser, name=name, **kwargs)