Skip to main content
Gathering Interest

Enable use of standard logging library in python for Cognite Functions

Related products:Functions
  • August 1, 2024
  • 3 replies
  • 24 views

Hi, sure this has been raised before, but would it be too much to ask to enable standard logging calls in Python when using Cognite Functions. 

While I am fully aware that it works to use print statements instead, it is very contrary to expectations for most developers that logging would not work, also for your own consultants (various Cognite consultants on our projects have themselves converted print statements to logger.info calls in the name of “best practice”, only to be surprised that nothing gets printed out). Moreover it gives the impression that the product is not quite “working” or that there is “something weird going on”.
 

I would consider it similar to a cosmetic UX defect which is easy to work around: sometimes hard to prioritise, but affects the overall impression of the product when things do not work as expected. Maybe it is time to give it some TLC.

3 replies

Jørgen Lund
Seasoned Practitioner
Forum|alt.badge.img
  • Product Manager
  • August 2, 2024

Hi @Malcolm Lea .

Thank you for suggesting this product idea. We will follow the traction this idea gets in the community. You can expect updates on this post if we decide to include this in our future roadmap, or if we require more information.


Jørgen Lund
Seasoned Practitioner
Forum|alt.badge.img
  • Product Manager
  • August 13, 2024

Hi @Malcolm Lea. Understand your request and see the value of supporting standard logging in Functions.

For Functions in CDF projects on Azure, we use a logger called cognite-logger , which you can use (logger = logging.getLogger("cognite-logger") ) and any log statements produced using this should show up as expected. So if you’re working on a project on Azure you should already be able to leverage this.

We want to support logging in Functions in a common way across cloud providers, but it’s currently not on our short term roadmap. We’ll give you an update when that changes.


  • Author
  • Committed
  • August 13, 2024

Thanks for the response Jørgen. Unfortunately we are not on Azure though so will have to wait. It just seems really strange that something most would regard as a core part of the language would be unsupported, especially (when print statements written to stdout work just fine).

Is it possible to shed some light on what makes this tricky to implement?