asgaard.utils.log
Class LogClient

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--asgaard.utils.log.LogClient

public class LogClient
extends java.lang.Thread

LogClient is a wrapper for local and remote Logserver and does the Exception-handling. To guarantee a minimum performance this is implemented as Thread which can be used or not as a Thread.


Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
LogClient(java.lang.String pre, boolean start)
          Creates a local LogClient, wrapping a local Logfile with the default directory.
LogClient(java.lang.String pre, java.lang.String server, boolean start)
          Creates a local LogClient, wrapping a remote Logserver.
LogClient(java.lang.String pre, java.lang.String localPath, byte mailLevel, java.lang.String mailTO, java.lang.String clientName, java.lang.String mailCC, java.lang.String mailHOST, long size, boolean start)
          Creates a local LogClient, wrapping a local Logfile and setup a mailclient.
 
Method Summary
 LogMsg[] get(long nr, boolean withBean)
          Gets a Statement from the wrapped LOGFILE returning the Statement-bean.
 boolean isRemote()
          Is the current Logfile remote?
 void put(LogMsg stmt)
          Puts a Statement into the wrapped LOGFILE.
 void put(java.lang.String server, java.lang.String point, byte typ, boolean ok, java.lang.String msg)
          Creates a Statement out of the Message If any Exception rises it will be ignored
 void put(java.lang.String server, java.lang.String point, byte typ, boolean ok, java.lang.String msg, java.lang.Object bean)
          Creates a Statement out of the Message If any Exception rises it will be ignored
 void putBackup(java.lang.String server, java.lang.String point, java.lang.String msg, java.lang.Object bean)
          Creates a Backup-Statement out of the Message If any Exception rises it will be ignored
 void run()
          Does the work for put as a Thread
 void setMailServer(byte level, java.lang.String to, java.lang.String from, java.lang.String cc, java.lang.String mailhost, long size)
          Defines a Mailserver for automatically forward LOGMSG also via eMail.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LogClient

public LogClient(java.lang.String pre,
                 boolean start)
          throws java.io.IOException,
                 java.sql.SQLException
Creates a local LogClient, wrapping a local Logfile with the default directory.
Parameters:
pre - prefix printed to System.err in case of an Exception
start - runs the LogClient as Thread
Throws:
java.sql.SQLException - if the JDBC connection to the local flatfile (logfile) failes
java.io.IOException - if the access to the local flatfile (logfile) failes

LogClient

public LogClient(java.lang.String pre,
                 java.lang.String localPath,
                 byte mailLevel,
                 java.lang.String mailTO,
                 java.lang.String clientName,
                 java.lang.String mailCC,
                 java.lang.String mailHOST,
                 long size,
                 boolean start)
          throws java.io.IOException,
                 java.sql.SQLException
Creates a local LogClient, wrapping a local Logfile and setup a mailclient.
Parameters:
pre - prefix printed to System.err in case of an Exception
localPath - path for the local logfile
mailLevel - mail statements up to specified level
mailTO - adress of to send the statements
clientName - name of the client-task (\@[host] is added automatically)
mailCC - adress of to send the statements
mailHOST - mail host
size - maximum size of the logfile
start - runs the LogClient as Thread
Throws:
java.sql.SQLException - if the JDBC connection to the local flatfile (logfile) failes
java.io.IOException - if the access to the local flatfile (logfile) failes

LogClient

public LogClient(java.lang.String pre,
                 java.lang.String server,
                 boolean start)
          throws java.io.IOException,
                 java.sql.SQLException
Creates a local LogClient, wrapping a remote Logserver. If the connection to the remote Logserver failes a default local Log is created.
Parameters:
pre - prefix printed to System.err in case of an Exception
server - name of the Logserver host
start - runs the LogClient as Thread
Throws:
java.sql.SQLException - if the JDBC connection to the local flatfile (logfile) failes (backup routine after remote failue)
java.io.IOException - if the access to the local flatfile (logfile) failes (backup routine after remote failue)
Method Detail

run

public void run()
Does the work for put as a Thread
Overrides:
run in class java.lang.Thread

setMailServer

public void setMailServer(byte level,
                          java.lang.String to,
                          java.lang.String from,
                          java.lang.String cc,
                          java.lang.String mailhost,
                          long size)
Defines a Mailserver for automatically forward LOGMSG also via eMail.
Parameters:
level - Which Error-Level should be forwarded
to - mailto - eMailadress
from - eMailadress
cc - carbon copy (optional)
mailhost - assumption: mail.smtp.host
logsize - send warning if logfile exceeds size (0 for no warning)

put

public void put(LogMsg stmt)
Puts a Statement into the wrapped LOGFILE. If the Statement exists already, it is replaced. If any Exception rises it will be ignored
Parameters:
stmt - Statement as a LogMsg-Bean
See Also:
LogMsg

put

public void put(java.lang.String server,
                java.lang.String point,
                byte typ,
                boolean ok,
                java.lang.String msg)
Creates a Statement out of the Message If any Exception rises it will be ignored
Parameters:
server - The calling Java-Serverclass
point - The Method / place where the statement was created
typ - The Type of the LOG-Statement
ok - Was the ServicePoint passed successfuly
msg - Human redable Message of the Statement
See Also:
LogMsg

put

public void put(java.lang.String server,
                java.lang.String point,
                byte typ,
                boolean ok,
                java.lang.String msg,
                java.lang.Object bean)
Creates a Statement out of the Message If any Exception rises it will be ignored
Parameters:
server - The calling Java-Serverclass
point - The Method / place where the statement was created
typ - The Type of the LOG-Statement
ok - Was the ServicePoint passed successfuly
msg - Human redable Message of the Statement
bean - Some streamable Object
See Also:
LogMsg

putBackup

public void putBackup(java.lang.String server,
                      java.lang.String point,
                      java.lang.String msg,
                      java.lang.Object bean)
Creates a Backup-Statement out of the Message If any Exception rises it will be ignored
Parameters:
server - The calling Java-Serverclass
point - The Method / place where the statement was created
typ - The Type of the LOG-Statement
ok - Was the ServicePoint passed successfuly
msg - Human redable Message of the Statement
bean - Some streamable Object
See Also:
LogMsg

get

public LogMsg[] get(long nr,
                    boolean withBean)
Gets a Statement from the wrapped LOGFILE returning the Statement-bean.
Parameters:
nr - Number of the statement in the current Logfile
withBean - if the Bean carried by the Statement is required
Returns:
a List with the found Statement-Beans
See Also:
LogMsg

isRemote

public boolean isRemote()
Is the current Logfile remote?