How to print from within lambda code to the log

To troubleshoot ESPHOME code I can print to the logger without any problem. My challenge is to print to the logger from within lambda code blocks? I have read the logger component, but that doesn’t bring me any further. Below my code block where I want to print: logger.log: “write to the log: Temperature too high” The command obviously works outside the lambda block, but I can’t find what it needs to be within the lambda code block.

    on_time:
      - seconds: 0  
        minutes: '*'  
        then:
          lambda: !lambda |-
            auto time = id(homeassistant_time).now();
            if (id(CV_Floor_Pump_Temp_In).has_state() >= 44) 
              {
              id(Relay01).turn_off();
              logger.log: "write to the log: Temperature too high"
              id(CV_Floor_Pump_TemperatureTooHigh).turn_on();
              }

Thanks in advance

2 Likes

ESP_LOGD

2 Likes