[request] want options to redirect Sikuli's log messages to my own logging
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SikuliX |
Fix Committed
|
Critical
|
RaiMan |
Bug Description
A previous thread that is closest to answering my current question is:
https:/
in which RaiMan suggest the usage of a setSikuliXLogCa
I searched the net for setSikuliXLogCa
I recently started looking into Sikuli using IDE first, then I moved onto using standalone Jython, and then finally had the courage to venture into using Ruby, which is the primary language of my test framework.
I was pleasantly surprised how easy and great the interface was. Kudos to RaiMan and contributors on this great tool.
Now, onto my question...
I can redirect the java output to a single log file via Debug.setLogFil
My test framework, however, uses Log4R which direct the log output to multiple files as well as the console.
Ideally I would like to redirect the logging requests to my logger to do it's thing, so that I can get all the output like:
[LOG] CLICK on L(27,10)@S(0)[0,0 1440x900]
in the standard log files.
I kind-a implemented a workaround that does this as follows:
1. I put in a one-line callback patch in the native_
2. Redirected the java logs to a temp file first, by defining and calling the following:
module SikuliLib
def self.log_
@@log_file = log_file
Debug.
end
3. Captured the original logoutput and logged it via myLogger as such:
module SikuliX4Ruby
def self.post_
file = SikuliLib.log_file
File.
FileUtils.rm file
end
end
My workaround does the trick for now, but I'm not happy about the fact that I had to copy and patch the sikulix.rb file.
I would rather not muck with original SikuliX distribution files and use a callback that is officially supported, if there is one (The previous question thread hinted that there might be one already.)
Changed in sikuli: | |
status: | In Progress → Fix Committed |
importance: | Medium → Critical |
this is my idea about how to implement this:
you have some logger instance (e.g. myLogger), which in turn has some methods like .info, .error, .warning, ...., that accept a string as the one and only parameter.
now you can tell Debug to redirect to your logger using one of these methods:
Debug.setLogger Info(myLogger, "info"); Action( myLogger, "whatever"); Error(myLogger, "whatever"); Debug(myLogger, "whatever");
Debug.setLogger
Debug.setLogger
Debug.setLogger
according to the message groups Settings.ActionLogs ( [log] ), Settings.InfoLogs( [info] ), Settings.DebugLogs ( [debug] )
additionally we have the error group ( [error] )
From now on messages created using Debug.info() would be redirected to myLogger. info(original_ message) using reflection (the reason for the string parameter, to avoid the Java interface/callback implementation overhead).
question: should the prefix [.....] be contained in the message or would this be more flexible: (myLogger) Info("info" , "new prefix"); Action( "whatever" , "new prefix"); Error( "whatever", "new prefix"); Debug(" whatever" , "new prefix");
Debug.setLogger
Debug.setLogger
Debug.setLogger
Debug.setLogger
Debug.setLogger
additionally this could be convenient: All(myLogger, "whatever", "new prefix");
Debug.setLogger
which would return a message debug/error] message
[new prefix log/info/