molgenis / molgenis-emx2

MOLGENIS EMX2, the latest version of the MOLGENIS data platform.
GNU Lesser General Public License v3.0
13 stars 16 forks source link

Log messages do not display properly for (Python) tasks #3628

Open YpeZ opened 4 months ago

YpeZ commented 4 months ago

What version of EMX2 are you using (see footer) v10.53.0

Describe the bug Running Python script tasks that include logging, results in all logging messages being grouped together in one 'error' line at the end of the output (see screenshot). Simple print statements are shown in 'real time'.

To Reproduce Steps to reproduce the behavior:

  1. Go to 'https://emx2.test.molgenis.org'
  2. Sign in as admin
  3. Go to https://emx2.dev.molgenis.org/_SYSTEM_/tasks/#/Scripts
  4. Execute the 'logging test' script

Expected behavior The solution I would like to see is INFO messages displayed in green lines, DEBUG messages in yellow lines, and ERROR messages in red lines, all presented in real time.

Screenshots Output on dev server image Output in IDE

image
YpeZ commented 4 months ago

Workaround: by default, the logging library sends logging messages to stderr. Redirecting the logging to the stdout stream puts the log messages among the normal print messages. Use as follows:

import logging
import sys

logging.basicConfig(level='DEBUG', stream=sys.stdout)

Result: image