Class RedirectableFileLogger

java.lang.Object
gda.factory.ConfigurableBase
gda.jython.logger.RedirectableFileLogger
All Implemented Interfaces:
Configurable, LineLogger, gda.observable.IObserver

public class RedirectableFileLogger extends ConfigurableBase implements LineLogger, gda.observable.IObserver
A RedirectableLogger logs strings to a file maintained by the instance and to a standard slf4j logger. The log file's location will be updated upon receipt of PathChanged events from a configured ObservablePathProvider. When the file location changes, a note will left in the last file directing a reader to the new file, and a note will be made in the new file indicating where the log came from.

This might be used for example to create a server-side logger that mirrors everything from a Jython terminal window to a log file in the current visit directory. This should typically be done in Spring by wiring into a server's JythonServerFacade and command-server through adaptors. For example, given that a JythonServer has been made (always named 'command_server'), try this to get a JythonServerFacade reference:


 
       invalid input: '<'constructor-arg ref="command_server" />
 
 

and then the following to build up a typical logger:

 
             invalid input: '<'constructor-arg ref="terminallog_path_provider" />
 
 
             invalid input: '<'constructor-arg ref="jython_server_facade" />
             invalid input: '<'constructor-arg ref="terminal_logger"/>
 
 
      invalid input: '<'constructor-arg ref="command_server" />
      invalid input: '<'constructor-arg ref="terminal_logger"/>
 
 
             invalid input: '<'constructor-arg ref="jython_server_facade" />
             invalid input: '<'constructor-arg ref="terminal_logger"/>
 
 
             invalid input: '<'constructor-arg ref="jython_server_facade" />
       invalid input: '<'constructor-arg ref="terminal_logger"/>
        

 

where the terminallog_path_provider bean might be a dummy:

        
                
                
        
 

or a one that tracks the server's visit metadata:

        
                
                
                
 

  • Constructor Details

  • Method Details

    • configure

      public void configure()
      Description copied from class: ConfigurableBase
      Default implementation for classes that do not have to do any specific configuration.
      Classes that do their own configuration should *not* call this superclass function, as it may cause the object to appear configured before it really is.
      Specified by:
      configure in interface Configurable
      Overrides:
      configure in class ConfigurableBase
    • getFile

      public String getFile()
    • log

      public void log(String msg)
      Specified by:
      log in interface LineLogger
    • update

      public void update(Object source, Object event)
      Specified by:
      update in interface gda.observable.IObserver