API for logging - clojure-contrib v1.1 (stable)

by Alex Taggart, Timothy Pratley

clojure-contrib is now deprecated

clojure-contrib is no longer being developed or maintained.

Rather than a single, monolithic, contributions library, Clojure now has a set of separate libraries for each unit of functionality. The libraries are in the Clojure GitHub organization at https://github.com/clojure. API documentation of the libraries can be found at https://clojure.github.io.

If you're looking for a specific function or namespace from the old clojure-contrib, see "Where Did Clojure.Contrib Go".


Full namespace name: clojure.contrib.logging

Overview

Logging macros which delegate to a specific logging implementation. At
macro-expansion-time a specific implementation is selected from, in order,
Apache commons-logging, log4j, and finally java.util.logging.

Logging levels are specified by clojure keywords corresponding to the
values used in log4j and commons-logging:
  :trace, :debug, :info, :warn, :error, :fatal

Logging occurs with the log macro, or the level-specific convenience macros,
which write either directly or via an agent.  For performance reasons, direct
logging is enabled by default, but setting the *allow-direct-logging* boolean
atom to false will disable it. If logging is invoked within a transaction it
will always use an agent.

The log macros will not evaluate their 'message' unless the specific logging
level is in effect. Alternately, you can use the spy macro when you have code
that needs to be evaluated, and also want to output the code and its result to
the debug log.

Unless otherwise specified, the current namespace (as identified by *ns*) will
be used as the log-ns (similar to how the java class name is usually used).
Note: your log configuration should display the name that was passed to the
logging implementation, and not perform stack-inspection, otherwise you'll see
something like "fn__72$impl_write_BANG__39__auto____81" in your logs.

Use the enabled? macro to write conditional code against the logging level
(beyond simply whether or not to call log, which is handled automatically).

You can redirect all java writes of System.out and System.err to the log
system by calling log-capture!.  To rebind *out* and *err* to the log system
invoke with-logs.  In both cases a log-ns (e.g., "com.example.captured")
needs to be specified to namespace the output.

Public Variables and Functions



*allow-direct-logging*

var
This library, clojure-contrib, is deprecated. See here for more information.

  
A boolean indicating whether direct logging (as opposed to via an agent) is
allowed when not operating from within a transaction. Defaults to true.
Source


*impl-name*

var
This library, clojure-contrib, is deprecated. See here for more information.

  
The name of the logging implementation used.
Source


*logging-agent*

var
This library, clojure-contrib, is deprecated. See here for more information.

  
The default agent used for performing logging durng a transaction or when
direct logging is disabled.
Source


agent-write!

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (agent-write! _ log level message throwable)
Writes the message immediately, and ignores the first argument. Used by the
logging agent. End-users should never need to call this function.
Source


debug

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (debug message)
       (debug message throwable)
Logs a message at the debug level.
Source


enabled?

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (enabled? level)
       (enabled? level log-ns)
Returns true if the specific logging level is enabled.  Use of this function
should only be necessary if one needs to execute alternate code paths beyond
whether the log should be written to.
Source


error

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (error message)
       (error message throwable)
Logs a message at the error level.
Source


fatal

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (fatal message)
       (fatal message throwable)
Logs a message at the fatal level.
Source


impl-enabled?

var
This library, clojure-contrib, is deprecated. See here for more information.

  
Implementation-specific check if a particular level is enabled. End-users
should not need to call this function.
Source


impl-get-log

var
This library, clojure-contrib, is deprecated. See here for more information.

  
Returns an implementation-specific log by string namespace. End-users should
not need to call this function.
Source


impl-write!

var
This library, clojure-contrib, is deprecated. See here for more information.

  
Implementation-specific write of a log message. End-users should not need to
call this function.
Source


info

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (info message)
       (info message throwable)
Logs a message at the info level.
Source


log

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (log level message)
       (log level message throwable)
       (log level message throwable log-ns)
Logs a message, either directly or via an agent. Also see the level-specific
convenience macros.
Source


log-capture!

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (log-capture! log-ns)
Captures System.out and System.err, redirecting all writes of those streams
to :info and :error logging, respectively. The specified log-ns value will
be used to namespace all redirected logging. NOTE: this will not redirect
output of *out* or *err*; for that, use with-logs.
Source


log-stream

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (log-stream level log-ns)
Creates a PrintStream that will output to the log. End-users should not need
to invoke this function.
Source


log-uncapture!

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (log-uncapture!)
Restores System.out and System.err to their original values.
Source


spy

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (spy expr)
Evaluates expr and outputs the form and its result to the debug log; returns
the result of expr.
Source


trace

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (trace message)
       (trace message throwable)
Logs a message at the trace level.
Source


warn

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (warn message)
       (warn message throwable)
Logs a message at the warn level.
Source


with-logs

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (with-logs log-ns & body)
Evaluates exprs in a context in which *out* and *err* are bound to :info and
:error logging, respectively. The specified log-ns value will be used to
namespace all redirected logging.
Source
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber.