Skip to main content
Question

Unique log file name containing username


dustin
Influencer
Forum|alt.badge.img+31

We currently have a single workbench stored in a central location being accessed and ran by various users, at various times. I would like to be able to incorporate the individuals system username into the log file name, as well as the date/time when they ran it. Is this possible?

2 replies

daveatsafe
Safer
Forum|alt.badge.img+19
  • Safer
  • June 27, 2018

Hi @cartoscro,

This should be possible using Python scripted parameters. The location of the logfile is a workspace parameter that is normally left blank. However, if populated, it will override the default logfile location.

You can right-click on the Log File setting and create a non-Published User Parameter. This makes it settable by a Python scripted Parameter. We have a tutorial on using Scripted parameters available here.

The timestamp is simple, but getting the username in Python may be more complex. There is a good conversation on how to do it in Stack Overflow.


dustin
Influencer
Forum|alt.badge.img+31
  • Author
  • Influencer
  • July 27, 2018

For future reference, I ended up using this along with @DaveAtSafe suggestion to get the username, workbench name, and date/time appended to the logfile name.

import getpass, time, os

n = getpass.getuser()
w = FME_MacroValues['FME_MF_NAME']
t = time.strftime('%Y_%m_%d_%H_%M_%S')

if w.endswith('.fmw'):
	w = w[:-4]

path = n + '_' + w + '_' + t
return path

Easier than I thought it would be.


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