Solved

How to get log generated in custom transformer ?

  • 11 August 2021
  • 2 replies
  • 19 views

I have a workbench which has a complex custom transformer added in which a python caller is present. I wanted to check what is happening in that python caller so I used some print statements. But I cannot find those print statements in logs that is being generated. How to get the log of a custom transformer in FME Desktop 2019.

icon

Best answer by david_r 11 August 2021, 14:11

View original

2 replies

Userlevel 4

Print statements will appear in the on-screen log window, but will not necessarily be logged in the exact same order as the transformer messages, and may only appear on-screen and not in the log file. 

The best way to log messages is to use the FMELogFile object in the fmeobjects API. Example:

import fmeobjects
 
def my_function(feature):
    # Do something ...
    
    # Sends a message to the FME log file and console window.
    # Severity must be one of FME_INFORM, FME_WARN, FME_ERROR,
    # FME_FATAL, FME_STATISTIC, or FME_STATUSREPORT.
    message = 'This message will appear both on screen and in the log file'
    severity = fmeobjects.FME_INFORM
    fmeobjects.FMELogFile().logMessageString(message, severity)
 
    # Do something else here...

 

Print statements will appear in the on-screen log window, but will not necessarily be logged in the exact same order as the transformer messages, and may only appear on-screen and not in the log file. 

The best way to log messages is to use the FMELogFile object in the fmeobjects API. Example:

import fmeobjects
 
def my_function(feature):
    # Do something ...
    
    # Sends a message to the FME log file and console window.
    # Severity must be one of FME_INFORM, FME_WARN, FME_ERROR,
    # FME_FATAL, FME_STATISTIC, or FME_STATUSREPORT.
    message = 'This message will appear both on screen and in the log file'
    severity = fmeobjects.FME_INFORM
    fmeobjects.FMELogFile().logMessageString(message, severity)
 
    # Do something else here...

 

Got it.. Thanks 

Reply