org.talika.tarsis.log
Class FileLogger

java.lang.Object
  extended by org.talika.tarsis.service.AbstractService
      extended by org.talika.tarsis.log.LoggerService
          extended by org.talika.tarsis.log.FileLogger
All Implemented Interfaces:
Logger, Service

public final class FileLogger
extends LoggerService

Implementation of Logger interface that writes messages to a given file.

Version:
$Revision: 124 $
Author:
Jose M. Palomar

Field Summary
 
Fields inherited from interface org.talika.tarsis.log.Logger
DEBUG, ERROR, INFO, PANIC, WARNING
 
Constructor Summary
FileLogger()
          Creates a new FileLogger.
 
Method Summary
 void destroy()
          Called by the framework to indicate that is being placed out of service.
 java.lang.String getLogFileName()
          Returns log file name parameter.
 java.lang.String getName()
          Returns name of service.
 void init(Context context)
          Called by the framework to indicate that is being placed into service.
 void setLogFileName(java.lang.String logFileName)
          Sets log file name parameter.
protected  void writeLog(int level, java.lang.String msg)
          Writes a log message to log file.
protected  void writeLog(int level, java.lang.String msg, java.lang.Throwable t)
          Writes an error log message to log file.
 
Methods inherited from class org.talika.tarsis.log.LoggerService
formatLog, getLogLevel, isDebugEnabled, isErrorEnabled, isInfoEnabled, isPanicEnabled, isWarningEnabled, log, log, logDebug, logError, logInfo, logPanic, logPanic, logWarning, setLogLevel
 
Methods inherited from class org.talika.tarsis.service.AbstractService
getContext, getLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileLogger

public FileLogger()
Creates a new FileLogger.

Method Detail

init

public void init(Context context)
          throws ServiceException
Called by the framework to indicate that is being placed into service.

Opens existing log file or creates a new one.

Specified by:
init in interface Service
Overrides:
init in class AbstractService
Parameters:
context - Context context that initialized service.
Throws:
ServiceException - if an exception has occurred that interferes with the services's normal operation
See Also:
Service.init(Context)

destroy

public void destroy()
Called by the framework to indicate that is being placed out of service.

Closes log file.

Specified by:
destroy in interface Service
Overrides:
destroy in class AbstractService
See Also:
Service.destroy()

getName

public java.lang.String getName()
Returns name of service.

Specified by:
getName in interface Service
Specified by:
getName in class AbstractService
Returns:
String name of service.
See Also:
Service.getName()

setLogFileName

public void setLogFileName(java.lang.String logFileName)
Sets log file name parameter.

Parameters:
logFileName - String file name parameter.

getLogFileName

public java.lang.String getLogFileName()
Returns log file name parameter.

Returns:
String file name parameter.

writeLog

protected void writeLog(int level,
                        java.lang.String msg)
Writes a log message to log file.

Specified by:
writeLog in class LoggerService
Parameters:
level - int log level.
msg - String message.

writeLog

protected void writeLog(int level,
                        java.lang.String msg,
                        java.lang.Throwable t)
Writes an error log message to log file.

Specified by:
writeLog in class LoggerService
Parameters:
level - int log level.
msg - String message.
t - Throwable a Throwable object.


Copyright © 2002-2012 Talika Open Source Group. All Rights Reserved.