Here is a work-around for Python:
Put the following in a my_module.py in
C:\Users\User\AppData\Roaming\Sikulix\Lib\site-packages and in sikuli
scripts use from my_module import *:
#----------start of my_module.py----------#
from org.sikuli.basics import Debug as SikuliDebug
from org.sikuli.basics import Settings as SikuliSettings
import datetime
class Debug(SikuliDebug):
printoutuser = None
@staticmethod
def setUserLogFile(fileName):
if fileName == None:
fileName = ""
if fileName != None:
if "" == fileName:
if Settings.isMacApp:
Debug.printoutuser = "UserLog.txt"
else:
Debug.printoutuser = getBundleFolder()+
"UserLog.txt"
try:
Debug.printoutuser = fileName
with open(Debug.printoutuser, "a") as f:
f.write("")
return True
except:
print "[Error] User logfile %s not accessible -
check given path"% fileName
return False
return False;
@staticmethod
def user(message):
if SikuliSettings.UserLogs:
with open(Debug.printoutuser, "a") as f:
if SikuliSettings.UserLogTime:
text = '[{} ({})]
{}'.format(SikuliSettings.UserLogPrefix,'{:%m/%d/%y %I:%M:%S
%p}'.format(datetime.datetime.now()).lstrip("0").replace(" 0", " "), message)
else:
text = '[{}]
{}'.format(SikuliSettings.UserLogPrefix, message)
f.write(text+"\n")
#----------end of my_module.py----------#
--
You received this bug notification because you are a member of Sikuli
Drivers, which is subscribed to Sikuli.
https://bugs.launchpad.net/bugs/1523582
Title:
[request] want an option to append user logs to existing file
Status in Sikuli:
In Progress
Bug description:
Is there an option for write into a log file without overwriting the file?
Sikuli 1.1.0
My script looks like:
Settings.UserLogs=True
Settings.UserLogPrefix="Alexander"
Settings.UserLogTime=True
Debug.setUserLogFile("path\MyLogs.txt")
Debug.user("text")
To manage notifications about this bug go to:
https://bugs.launchpad.net/sikuli/+bug/1523582/+subscriptions
_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to : [email protected]
Unsubscribe : https://launchpad.net/~sikuli-driver
More help : https://help.launchpad.net/ListHelp