You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2021/01/08 22:46:56 UTC

[airflow] branch master updated: Stop Log Spamming when `[core] lazy_load_plugins` is False (#13578)

This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/master by this push:
     new 52a5ecf  Stop Log Spamming when `[core] lazy_load_plugins` is False (#13578)
52a5ecf is described below

commit 52a5ecf45073d8579ebe9ebbd840492b62790b06
Author: Kaxil Naik <ka...@gmail.com>
AuthorDate: Fri Jan 8 22:46:44 2021 +0000

    Stop Log Spamming when `[core] lazy_load_plugins` is False (#13578)
    
    * Stop Log Spamming when `[core] lazy_load_plugins` is False
    
    Currently when `[core] lazy_load_plugins` is False, it spams logs with the following line:
    
    ```
    Loading 1 plugin(s) took 0.79 seconds
    ```
    
    Example
    
    ```
    root@a20fe6919413:/usr/local/airflow# python
    Python 3.7.9 (default, Dec 11 2020, 14:53:17)
    [GCC 8.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from airflow import version
    [2021-01-08 20:20:51,730] {plugins_manager.py:286} INFO - Loading 1 plugin(s) took 0.79 seconds
    ```
---
 airflow/plugins_manager.py            | 2 +-
 tests/plugins/test_plugins_manager.py | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/airflow/plugins_manager.py b/airflow/plugins_manager.py
index c13ad60..b68dbb9 100644
--- a/airflow/plugins_manager.py
+++ b/airflow/plugins_manager.py
@@ -283,7 +283,7 @@ def ensure_plugins_loaded():
 
     num_loaded = len(plugins)
     if num_loaded > 0:
-        log.info("Loading %d plugin(s) took %.2f seconds", num_loaded, timer.duration)
+        log.debug("Loading %d plugin(s) took %.2f seconds", num_loaded, timer.duration)
 
 
 def initialize_web_ui_plugins():
diff --git a/tests/plugins/test_plugins_manager.py b/tests/plugins/test_plugins_manager.py
index e8271fb..c9d165e 100644
--- a/tests/plugins/test_plugins_manager.py
+++ b/tests/plugins/test_plugins_manager.py
@@ -125,13 +125,14 @@ class TestPluginsManager:
         with mock_plugin_manager(plugins=[AirflowTestPropertyPlugin()]):
             from airflow import plugins_manager
 
+            caplog.set_level(logging.DEBUG)
             plugins_manager.ensure_plugins_loaded()
 
             assert 'AirflowTestPropertyPlugin' in str(plugins_manager.plugins)
             assert 'TestPropertyHook' in str(plugins_manager.registered_hooks)
 
-        assert caplog.records[0].levelname == 'INFO'
-        assert caplog.records[0].msg == 'Loading %d plugin(s) took %.2f seconds'
+        assert caplog.records[-1].levelname == 'DEBUG'
+        assert caplog.records[-1].msg == 'Loading %d plugin(s) took %.2f seconds'
 
     def test_should_warning_about_incompatible_plugins(self, caplog):
         class AirflowAdminViewsPlugin(AirflowPlugin):