VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   Default log file name changed after script is ran. (https://forums.vandyke.com/showthread.php?t=14607)

pichi 08-27-2021 10:34 AM

Default log file name changed after script is ran.
 
Hello VanDyke team,

I have in the session option the default log file name set as follows "V:\logs\%S_%Y_%M%D.log" but every time I run a script that logs to a specific log file name and closes it, when I open the session again and want to log the work done the default session log file name is changed to the name last used in the script e.g "V:\script_log_date.log", Is there a way to keep the default log file name as specified in the session option after the script is complete "V:\logs\%S_%Y_%M%D.log"?

thanks for your support.

gregg 08-30-2021 11:26 AM

I think one way to accomplish this is to capture the current name, set new name, start log, reset name.

Code:

# $language = "Python"
# $interface = "1.0"

s = crt.Session
config = s.Config
orig_name = config.GetOption("Log Filename")
s.LogFileName = "my-new-file.log"
s.Log(False)
s.Log(True, True)
s.LogFileName = orig_name

# rest of script / terminal work

Changing the LogFileName after starting the log does not seem to affect the current log stream.

Note: had to use config.GetOption() to retain the raw "%S_%Y_%M%D" - because s.LogFileName returns the substituted name.


All times are GMT -6. The time now is 11:29 PM.