Skip to main content
Question

How to write a python script to log FME error to the database if the FME Workspace fails?

  • March 10, 2016
  • 1 reply
  • 16 views

Forum|alt.badge.img

vani.sm@techmahindra.com

1 reply

david_r
Celebrity
  • March 10, 2016

Hi

Using this pattern you can catch any error messages sent to the log window and access them in your shutdown script, e.g. for writing them to a database or a separate log file:

In the startup script we define a global list "my_fme_messages" and we tell FME to add all log file messages with a severity of WARN, ERROR or FATAL to it:

from fmeobjects import *
global my_fme_messages
my_fme_messages = []

def LogSkimmer(severity, text):
    if severity in (FME_WARN, FME_ERROR, FME_FATAL):
        my_fme_messages.append(text)
 
FMELogFile().setCallBack(LogSkimmer)

In the shutdown script, we can then analyse "my_fme_messages" and do whatever we want with it:

import fme
if not fme.status:
    # Translation failed
    global my_fme_messages
    for msg in my_fme_messages:
        # Do something with the error message(s)
        print "Message was:", msg

David


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings