I am not using STAF LOG Service, but this piece of code:
<function name="logToMessageAndFile" scope="local">
<function-prolog>
This fuction Logs message to Stax Monitor and to a File
</function-prolog>
<function-list-args>
<function-required-arg name="log">
log
</function-required-arg>
<function-optional-arg name="indentLevel">
indentLevel
</function-optional-arg>
<function-optional-arg name="fileToLog">
fileToLog
</function-optional-arg>
</function-list-args>
<sequence>
<script>
if fileToLog is None:
fileToLog=fileToLogNotDefault
file = fileToLog
from datetime import datetime
timestamp=datetime.now().strftime('%H:%M:%S')
if type(log) == str:
# Ignore errors even if the string is not proper UTF-8 or has
# broken marker bytes.
# Python built-in function unicode() can do this.
log = unicode(log, "utf-8", errors="ignore")
else:
# Assume the log object has proper __unicode__() method
log = unicode(log)
log=log.encode('ascii', 'ignore')
stringToLog=timestamp+': '+ log
stringIndent=' '
if indentLevel is None:
f=open(file,'a')
f.write(' '+stringToLog)
f.write('\n')
f.close()
else:
stringIndent=''
spaces=int(indentLevel)*4
for count in range(0,spaces):
stringIndent=stringIndent+' '
f=open(file,'a')
f.write(stringIndent+stringToLog)
f.write('\n')
f.close()
</script>
<message>stringIndent+stringToLog</message>
</sequence>
</function>
2014-08-25 15:16 GMT+02:00 Sharon Lucas <luc...@us.ibm.com>:
> Assuming you're referring to using the STAF Log service to log information
> to a STAF log file (e.g. such as the STAX User Log file), the STAF Log
> service manages concurrent writing to STAF log files.
>
> --------------------------------------------------------------
> Sharon Lucas
> IBM Austin, luc...@us.ibm.com
> (512) 286-7313 or Tieline 363-7313
>
>
>
>
> From: Luca Robusto <lucarobu...@gmail.com>
> To: "staf-users@lists.sourceforge.net" <
> staf-users@lists.sourceforge.net>
> Date: 08/25/2014 04:17 AM
> Subject: [staf-users] concurrent access to write a file in a
> "paralleliterate"
> ------------------------------
>
>
>
> I have a STAX Paralleliterate with 10 thread with functions in python to
> write log on a file.
>
> I don't manage the concurrent writes, but logs are written in a "safe" way
> anyway.
>
> Who manages this concurrency in the right way in the STAX Engine?
>
> Thanks.
> ------------------------------------------------------------------------------
> Slashdot TV.
> Video for Nerds. Stuff that matters.
> http://tv.slashdot.org/_______________________________________________
> staf-users mailing list
> staf-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/staf-users
>
>
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds. Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users