Skip to main content
Question

Unique log file name containing username

  • June 27, 2018
  • 2 replies
  • 202 views

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?

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

daveatsafe
Safer
Forum|alt.badge.img+20
  • 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.