• BlackBerry Dynamics
  • Runtime library for Android applications
  • 12.0.1.79
SimpleLog Class Reference
Inheritance diagram for SimpleLog:
Log

Description

Simple implementation of Log that sends all enabled log messages, for all defined loggers, to System.err. The following system properties are supported to configure the behavior of this logger:

  • org.apache.commons.logging.simplelog.defaultlog - Default logging detail level for all instances of SimpleLog. Must be one of ("trace", "debug", "info", "warn", "error", or "fatal"). If not specified, defaults to "info".
  • org.apache.commons.logging.simplelog.log.xxxxx - Logging detail level for a SimpleLog instance named "xxxxx". Must be one of ("trace", "debug", "info", "warn", "error", or "fatal"). If not specified, the default logging detail level is used.
  • org.apache.commons.logging.simplelog.showlogname - Set to true if you want the Log instance name to be included in output messages. Defaults to false.
  • org.apache.commons.logging.simplelog.showShortLogname - Set to true if you want the last component of the name to be included in output messages. Defaults to true.
  • org.apache.commons.logging.simplelog.showdatetime - Set to true if you want the current date and time to be included in output messages. Default is false.
  • org.apache.commons.logging.simplelog.dateTimeFormat - The date and time format to be used in the output messages. The pattern describing the date and time format is the same that is used in java.text.SimpleDateFormat. If the format is not specified or is invalid, the default format is used. The default format is yyyy/MM/dd HH:mm:ss:SSS zzz.

In addition to looking for system properties with the names specified above, this implementation also checks for a class loader resource named "simplelog.properties", and includes any matching definitions from this resource (if it exists).

Author
Scott Sanders
Rod Waldhoff
Robert Burrell Donkin
Version
Id
SimpleLog.java 399221 2006-05-03 09:20:24Z dennisl

Notice

The following notice applies to the original API on which this API is based, and to its documentation. The documentation of this API has been revised from the original.

/*
 * Copyright (C) 2006 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

Public Member Functions

 SimpleLog (String name)
 Construct a simple log with given name. More...
 
void setLevel (int currentLogLevel)
 
int getLevel ()
 
final void debug (Object message)
 Logs a message with org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_DEBUG. More...
 
final void debug (Object message, Throwable t)
 Logs a message with org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_DEBUG. More...
 
final void trace (Object message)
 Logs a message with org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_TRACE. More...
 
final void trace (Object message, Throwable t)
 Logs a message with org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_TRACE. More...
 
final void info (Object message)
 Logs a message with org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_INFO. More...
 
final void info (Object message, Throwable t)
 Logs a message with org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_INFO. More...
 
final void warn (Object message)
 Logs a message with org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_WARN. More...
 
final void warn (Object message, Throwable t)
 Logs a message with org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_WARN. More...
 
final void error (Object message)
 Logs a message with org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_ERROR. More...
 
final void error (Object message, Throwable t)
 Logs a message with org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_ERROR. More...
 
final void fatal (Object message)
 Log a message with org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_FATAL. More...
 
final void fatal (Object message, Throwable t)
 Logs a message with org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_FATAL. More...
 
final boolean isDebugEnabled ()
 
final boolean isErrorEnabled ()
 
final boolean isFatalEnabled ()
 
final boolean isInfoEnabled ()
 
final boolean isTraceEnabled ()
 
final boolean isWarnEnabled ()
 

Static Public Attributes

static final int LOG_LEVEL_TRACE = 1
 "Trace" level logging. More...
 
static final int LOG_LEVEL_DEBUG = 2
 "Debug" level logging. More...
 
static final int LOG_LEVEL_INFO = 3
 "Info" level logging. More...
 
static final int LOG_LEVEL_WARN = 4
 "Warn" level logging. More...
 
static final int LOG_LEVEL_ERROR = 5
 "Error" level logging. More...
 
static final int LOG_LEVEL_FATAL = 6
 "Fatal" level logging. More...
 
static final int LOG_LEVEL_ALL = (LOG_LEVEL_TRACE - 1)
 Enable all logging levels.
 
static final int LOG_LEVEL_OFF = (LOG_LEVEL_FATAL + 1)
 Enable no logging levels.
 

Protected Member Functions

void log (int type, Object message, Throwable t)
 
void write (StringBuffer buffer)
 
boolean isLevelEnabled (int logLevel)
 Is the given log level currently enabled? More...
 

Protected Attributes

String logName = null
 The name of this simple log instance.
 
int currentLogLevel
 The current log level.
 

Static Protected Attributes

static final String systemPrefix
 All system properties used by SimpleLog start with this.
 
static final Properties simpleLogProps = new Properties()
 Properties loaded from simplelog.properties.
 
static final String DEFAULT_DATE_TIME_FORMAT
 The default format to use when formating dates.
 
static boolean showLogName = false
 Include the instance name in the log message?
 
static boolean showShortName = true
 Include the short name ( last component ) of the logger in the log message. More...
 
static boolean showDateTime = false
 Include the current time in the log message.
 
static String dateTimeFormat = DEFAULT_DATE_TIME_FORMAT
 The date and time format to use in the log message.
 
static DateFormat dateFormatter = null
 Used to format times.
 

Constructor & Destructor Documentation

◆ SimpleLog()

SimpleLog ( String  name)
Parameters
namelog name

Member Function Documentation

◆ setLevel()

void setLevel ( int  currentLogLevel)

Set logging level.

Parameters
currentLogLevelnew logging level

◆ getLevel()

int getLevel ( )

Get logging level.

◆ log()

void log ( int  type,
Object  message,
Throwable  t 
)
protected

Do the actual logging. This method assembles the message and then calls write() to cause it to be written.

Parameters
typeOne of the LOG_LEVEL_XXX constants defining the log level
messageThe message itself (typically a String)
tThe exception whose stack trace should be logged

◆ write()

void write ( StringBuffer  buffer)
protected

Write the content of the message accumulated in the specified StringBuffer to the appropriate output destination. The default implementation writes to System.err.

Parameters
bufferA StringBuffer containing the accumulated text to be logged

◆ isLevelEnabled()

boolean isLevelEnabled ( int  logLevel)
protected
Parameters
logLevelis this level enabled?

◆ debug() [1/2]

final void debug ( Object  message)
Parameters
messageto log
See also
org.apache.commons.logging.Log::debug(Object)

Implements Log.

◆ debug() [2/2]

final void debug ( Object  message,
Throwable  t 
)
Parameters
messageto log
tlog this cause
See also
org.apache.commons.logging.Log::debug(Object, Throwable)

Implements Log.

◆ trace() [1/2]

final void trace ( Object  message)
Parameters
messageto log
See also
org.apache.commons.logging.Log::trace(Object)

Implements Log.

◆ trace() [2/2]

final void trace ( Object  message,
Throwable  t 
)
Parameters
messageto log
tlog this cause
See also
org.apache.commons.logging.Log::trace(Object, Throwable)

Implements Log.

◆ info() [1/2]

final void info ( Object  message)
Parameters
messageto log
See also
org.apache.commons.logging.Log::info(Object)

Implements Log.

◆ info() [2/2]

final void info ( Object  message,
Throwable  t 
)
Parameters
messageto log
tlog this cause
See also
org.apache.commons.logging.Log::info(Object, Throwable)

Implements Log.

◆ warn() [1/2]

final void warn ( Object  message)
Parameters
messageto log
See also
org.apache.commons.logging.Log::warn(Object)

Implements Log.

◆ warn() [2/2]

final void warn ( Object  message,
Throwable  t 
)
Parameters
messageto log
tlog this cause
See also
org.apache.commons.logging.Log::warn(Object, Throwable)

Implements Log.

◆ error() [1/2]

final void error ( Object  message)
Parameters
messageto log
See also
org.apache.commons.logging.Log::error(Object)

Implements Log.

◆ error() [2/2]

final void error ( Object  message,
Throwable  t 
)
Parameters
messageto log
tlog this cause
See also
org.apache.commons.logging.Log::error(Object, Throwable)

Implements Log.

◆ fatal() [1/2]

final void fatal ( Object  message)
Parameters
messageto log
See also
org.apache.commons.logging.Log::fatal(Object)

Implements Log.

◆ fatal() [2/2]

final void fatal ( Object  message,
Throwable  t 
)
Parameters
messageto log
tlog this cause
See also
org.apache.commons.logging.Log::fatal(Object, Throwable)

Implements Log.

◆ isDebugEnabled()

final boolean isDebugEnabled ( )

Are debug messages currently enabled?

This allows expensive operations such as String concatenation to be avoided when the message will be ignored by the logger.

Implements Log.

◆ isErrorEnabled()

final boolean isErrorEnabled ( )

Are error messages currently enabled?

This allows expensive operations such as String concatenation to be avoided when the message will be ignored by the logger.

Implements Log.

◆ isFatalEnabled()

final boolean isFatalEnabled ( )

Are fatal messages currently enabled?

This allows expensive operations such as String concatenation to be avoided when the message will be ignored by the logger.

Implements Log.

◆ isInfoEnabled()

final boolean isInfoEnabled ( )

Are info messages currently enabled?

This allows expensive operations such as String concatenation to be avoided when the message will be ignored by the logger.

Implements Log.

◆ isTraceEnabled()

final boolean isTraceEnabled ( )

Are trace messages currently enabled?

This allows expensive operations such as String concatenation to be avoided when the message will be ignored by the logger.

Implements Log.

◆ isWarnEnabled()

final boolean isWarnEnabled ( )

Are warn messages currently enabled?

This allows expensive operations such as String concatenation to be avoided when the message will be ignored by the logger.

Implements Log.

Member Data Documentation

◆ showShortName

boolean showShortName = true
staticprotected

Defaults to true - otherwise we'll be lost in a flood of messages without knowing who sends them.

◆ LOG_LEVEL_TRACE

final int LOG_LEVEL_TRACE = 1
static

◆ LOG_LEVEL_DEBUG

final int LOG_LEVEL_DEBUG = 2
static

◆ LOG_LEVEL_INFO

final int LOG_LEVEL_INFO = 3
static

◆ LOG_LEVEL_WARN

final int LOG_LEVEL_WARN = 4
static

◆ LOG_LEVEL_ERROR

final int LOG_LEVEL_ERROR = 5
static

◆ LOG_LEVEL_FATAL

final int LOG_LEVEL_FATAL = 6
static