Esempio n. 1
0
def test_no_double_write_same_names():
    with get_temp_file_name() as tf_name:
        foo_logger_one = define_json_file_logger('foo', tf_name, DEBUG)
        foo_logger_two = define_json_file_logger('foo', tf_name, INFO)

        foo_logger_one.debug('logger one message')
        foo_logger_two.debug('logger two message')

        data = list(parse_json_lines(tf_name))
        assert len(data) == 1
        assert data[0]['name'] == 'foo'
        assert data[0]['msg'] == 'logger one message'
Esempio n. 2
0
def test_no_double_write_diff_names():
    with get_temp_file_name() as tf_name:
        foo_logger = define_json_file_logger('foo', tf_name, DEBUG)
        baaz_logger = define_json_file_logger('baaz', tf_name, DEBUG)

        foo_logger.debug('foo message')
        baaz_logger.debug('baaz message')

        data = list(parse_json_lines(tf_name))

        assert len(data) == 2
        assert data[0]['name'] == 'foo'
        assert data[0]['msg'] == 'foo message'
        assert data[1]['name'] == 'baaz'
        assert data[1]['msg'] == 'baaz message'
Esempio n. 3
0
def test_basic_logging():
    with get_temp_file_name() as tf_name:
        logger = define_json_file_logger('foo', tf_name, DEBUG)
        logger.debug('bar')

        data = list(parse_json_lines(tf_name))

        assert len(data) == 1
        assert data[0]['name'] == 'foo'
        assert data[0]['msg'] == 'bar'
Esempio n. 4
0
def test_write_dagster_meta():
    with get_temp_file_name() as tf_name:
        logger = define_json_file_logger('foo', tf_name, DEBUG)
        execution_context = create_test_runtime_execution_context(loggers=[logger])
        execution_context.debug('some_debug_message', context_key='context_value')
        data = list(parse_json_lines(tf_name))
        assert len(data) == 1
        assert data[0]['name'] == 'foo'
        assert data[0]['orig_message'] == 'some_debug_message'
        assert data[0]['context_key'] == 'context_value'