Python loguru.logger.disable() Examples
The following are 18
code examples of loguru.logger.disable().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
loguru.logger
, or try the search function
.
Example #1
Source File: _logger.py From SimpleSQLite with MIT License | 6 votes |
def set_logger(is_enable: bool, propagation_depth: int = 2) -> None: if is_enable: logger.enable(MODULE_NAME) else: logger.disable(MODULE_NAME) if propagation_depth <= 0: return tabledata.set_logger(is_enable, propagation_depth - 1) sqliteschema.set_logger(is_enable, propagation_depth - 1) try: import pytablereader pytablereader.set_logger(is_enable, propagation_depth - 1) except (ImportError, TypeError): pass
Example #2
Source File: _logger.py From pytablereader with MIT License | 6 votes |
def set_logger(is_enable, propagation_depth=2): if is_enable: logger.enable(MODULE_NAME) else: logger.disable(MODULE_NAME) if propagation_depth <= 0: return dataproperty.set_logger(is_enable, propagation_depth - 1) try: import simplesqlite simplesqlite.set_logger(is_enable, propagation_depth - 1) except (ImportError, TypeError): pass
Example #3
Source File: __main__.py From sqlitebiter with MIT License | 6 votes |
def initialize_logger(name: str, log_level: str) -> None: logger.remove() if log_level == QUIET_LOG_LEVEL: logger.disable(name) return if log_level == "DEBUG": log_format = ( "<level>{level: <8}</level> | " "<cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - <level>{message}</level>" ) else: log_format = "<level>[{level}]</level> {message}" logger.add(sys.stdout, colorize=True, format=log_format, level=log_level) logger.enable(name) ptr.set_logger(True) sqlite.set_logger(True) appconfigpy.set_logger(True)
Example #4
Source File: _logger.py From pytablewriter with MIT License | 6 votes |
def set_logger(is_enable: bool, propagation_depth: int = 1) -> None: if is_enable: logger.enable(MODULE_NAME) else: logger.disable(MODULE_NAME) if propagation_depth <= 0: return dataproperty.set_logger(is_enable, propagation_depth - 1) try: import simplesqlite simplesqlite.set_logger(is_enable, propagation_depth - 1) except ImportError: pass try: import pytablereader pytablereader.set_logger(is_enable, propagation_depth - 1) except ImportError: pass
Example #5
Source File: _logger.py From pingparsing with MIT License | 5 votes |
def set_logger(is_enable: bool, propagation_depth: int = 1) -> None: if is_enable: logger.enable(MODULE_NAME) else: logger.disable(MODULE_NAME) if propagation_depth <= 0: return subprocrunner.set_logger(is_enable, propagation_depth - 1)
Example #6
Source File: _logger.py From pingparsing with MIT License | 5 votes |
def disable(self, name): # pragma: no cover pass
Example #7
Source File: test_activation.py From loguru with MIT License | 5 votes |
def test_invalid_disable_name(name): with pytest.raises(TypeError): logger.disable(name)
Example #8
Source File: test_activation.py From loguru with MIT License | 5 votes |
def test_f_globals_name_absent_with_others(writer, f_globals_name_absent): logger.add(writer, format="{message}") logger.info("1") logger.enable(None) logger.disable("foobar") logger.enable("foo.bar") logger.disable(None) logger.info("2") logger.enable("foobar") logger.enable(None) logger.info("3") assert writer.read() == "1\n3\n"
Example #9
Source File: test_activation.py From loguru with MIT License | 5 votes |
def test_log_before_disable_f_globals_name_absent(writer, f_globals_name_absent): logger.add(writer, format="{message}") logger.enable(None) logger.debug("yes") logger.disable(None) logger.debug("nope") result = writer.read() assert result == "yes\n"
Example #10
Source File: test_activation.py From loguru with MIT License | 5 votes |
def test_log_before_enable_f_globals_name_absent(writer, f_globals_name_absent): logger.add(writer, format="{message}") logger.disable(None) logger.debug("nope") logger.enable(None) logger.debug("yes") result = writer.read() assert result == "yes\n"
Example #11
Source File: test_activation.py From loguru with MIT License | 5 votes |
def test_log_before_disable(writer): logger.add(writer, format="{message}") logger.enable("") logger.debug("yes") logger.disable("tests") logger.debug("nope") result = writer.read() assert result == "yes\n"
Example #12
Source File: test_activation.py From loguru with MIT License | 5 votes |
def test_log_before_enable(writer): logger.add(writer, format="{message}") logger.disable("") logger.debug("nope") logger.enable("tests") logger.debug("yes") result = writer.read() assert result == "yes\n"
Example #13
Source File: test_activation.py From loguru with MIT License | 5 votes |
def test_enable(writer, name, should_log): logger.add(writer, format="{message}") logger.disable("") logger.enable(name) logger.debug("message") result = writer.read() if should_log: assert result == "message\n" else: assert result == ""
Example #14
Source File: test_activation.py From loguru with MIT License | 5 votes |
def test_disable(writer, name, should_log): logger.add(writer, format="{message}") logger.disable(name) logger.debug("message") result = writer.read() if should_log: assert result == "message\n" else: assert result == ""
Example #15
Source File: test_add_sinks.py From loguru with MIT License | 5 votes |
def test_disabled_logger_in_sink(sink_with_logger): sink = sink_with_logger(logger) logger.disable("tests.conftest") logger.add(sink, format="{message}") logger.info("Disabled test") assert sink.out == "Disabled test\n"
Example #16
Source File: _logger.py From tcconfig with MIT License | 5 votes |
def set_logger(is_enable): if is_enable: logger.enable(MODULE_NAME) else: logger.disable(MODULE_NAME) simplesqlite.set_logger(is_enable) subprocrunner.set_logger(is_enable)
Example #17
Source File: logging.py From bot with MIT License | 5 votes |
def setup(): logging.basicConfig(handlers=[InterceptHandler()], level=logging.INFO) logger.disable("sqlalchemy.engine.base")
Example #18
Source File: conftest.py From CharGer with GNU General Public License v3.0 | 5 votes |
def caplog(_caplog): # noqa: F811 """A fixture to capture loguru logging messages. Copied from https://loguru.readthedocs.io/en/stable/resources/migration.html """ class PropagateHandler(logging.Handler): def emit(self, record): logging.getLogger(record.name).handle(record) logger.enable("charger") handler_id = logger.add(PropagateHandler(), format="{message}") yield _caplog logger.remove(handler_id) logger.disable("charger")