public void addInfoListener( LogListener ll )
Adds the specified LogListener from the list of listeners to receive a notification when info is printed. The method LogListener.messageLogged (ianywhere.ml.script.ServerContext) is called.
ll The LogListener to be notify.
The following code registers a listener of type MyLogListener to receive notifications of info messages.
// ServerContext serv_context; serv_context.addInfoListener(new MyLogListener(ll_out_file)); // The following code shows an example of processing those messages: class MyLogListener implements LogListener { FileOutputStream _out_file; public TestLogListener(FileOutputStream out_file) { _out_file = out_file; } public void messageLogged(ServerContext sc, LogMessage msg) { String type; String user; try { if (msg.getType() == LogMessage.ERROR) { type = "ERROR"; } else if (msg.getType() == LogMessage.WARNING) { type = "WARNING"; } else if (msg.getType() == LogMessage.INFO) { type = "INFO"; } else { type = "UNKNOWN!!!"; } user = msg.getUser(); if (user == null) { user = "NULL"; } _out_file.write(("Caught msg type=" + type + " user=" + user + " text=" +msg.getText() + "\n").getBytes() ); _out_file.flush(); } catch(Exception e) { // if we print the exception from processing an info message, // we may recurse indefinitely if (msg.getType() != LogMessage.ERROR) { // Print some error output to the MobiLink log. e.printStackTrace(); } } } } |
Discuss this page in DocCommentXchange. Send feedback about this page using email. |
Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1 |