com.phasmidsoftware.flog

Members list

Type members

Classlikes

case class AppendableLogger(appendable: Appendable & AutoCloseable & Flushable) extends Logger

Class to represent a Logger which is based on an Appendable (which must also be AutoCloseable and Flushable.

Class to represent a Logger which is based on an Appendable (which must also be AutoCloseable and Flushable.

Value parameters

appendable

an instance of Appendable with is also AutoCloseable and Flushable.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Logger
trait Flushable
trait AutoCloseable
class Object
trait Matchable
class Any
Show all
case class Flog(logger: Logger) extends AutoCloseable, Loggables

Simple functional logging class.

Simple functional logging class.

Here are the steps you need to follow to enable logging:

  • To instantiate a new instance of Flog, specifying the class for which you are logging: simply invoke the apply method: Flog[MyClass]. Assuming that you named the variable "flog", then "import flog._"

  • Create a String which will form the log message, follow it with "!!" (info), or "!?" (debug), or other method, and follow that with the expression you want to log. The construct in this form (including the message and "!!") will yield the value of the expression.

  • Most of the time, this is all you need to do (see README.md for much more information on this).

There are several ways to turn logging off (temporarily or permanently) once you've added the log expressions:

(0)
configure the logger (using logback.xml or similar) to ignore the particular log level;
(1)
replace the !! method with the |! method for each expression you wish to silence;
(2)
use a disabled Flog with flog.disabled (silences all flogging everywhere);
(3)
remove the !! expressions.

Value parameters

logger

the Logger which is to be used by this Flog.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait Loggables
trait AutoCloseable
class Object
trait Matchable
class Any
Show all
object Flog

Companion object to Flog.

Companion object to Flog.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Flog.type
case class GenericLogFunction(f: String => Any, enabled: Boolean) extends LogFunction

LogFunction which is a function of String => Unit (except that the String parameter is defined to be call-by-name). NOTE: the type of f must be (String => Any) because many suitable functions will in fact yield a non-Unit result.

LogFunction which is a function of String => Unit (except that the String parameter is defined to be call-by-name). NOTE: the type of f must be (String => Any) because many suitable functions will in fact yield a non-Unit result.

Value parameters

f

a function which takes a String and returns any type. It is expected that f causes some side-effect such as writing to a log file. The actual result of invoking f is ignored.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait LogFunction
class Object
trait Matchable
class Any
Show all
case class GenericLogger(logFunction: LogFunction) extends Logger

Class to represent a Logger which is based on a LogFunction.

Class to represent a Logger which is based on a LogFunction.

Value parameters

logFunction

the LogFunction.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Logger
trait Flushable
trait AutoCloseable
class Object
trait Matchable
class Any
Show all
trait LogFunction

LogFunction which, almost, extends String => Unit. BUT, and this is a big but, if you simply write type LogFunction = String => Unit, you won't get the benefit of call-by-name parameter handling.

LogFunction which, almost, extends String => Unit. BUT, and this is a big but, if you simply write type LogFunction = String => Unit, you won't get the benefit of call-by-name parameter handling.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object LogFunction

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
trait Loggable[-T]

A type class to enable objects to be rendered laconically as Strings for the purpose of logging.

A type class to enable objects to be rendered laconically as Strings for the purpose of logging.

Type parameters

T

the underlying type of the Loggable.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Loggable

Companion object to Loggable. This is where the compiler can find the various given instances of Loggable[T].

Companion object to Loggable. This is where the compiler can find the various given instances of Loggable[T].

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Loggable.type
trait Loggables

Trait to define methods for rendering instances of case classes (with their various parameters), containers (Seq and Option), etc..

Trait to define methods for rendering instances of case classes (with their various parameters), containers (Seq and Option), etc..

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Flog
object Loggables

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Loggables.type
case class LoggedException(e: Throwable) extends Exception

A specialized exception that indicates its underlying cause has already been logged.

A specialized exception that indicates its underlying cause has already been logged.

This exception is useful in scenarios where the original exception has been logged and there's no need to log it again, minimizing duplicate logs for the same issue.

Value parameters

e

the underlying cause of this exception.

Attributes

Supertypes
trait Product
trait Equals
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
trait Logger extends AutoCloseable, Flushable

Trait to represent a Logger.

Trait to represent a Logger.

Attributes

Companion
object
Supertypes
trait Flushable
trait AutoCloseable
class Object
trait Matchable
class Any
Known subtypes
object Logger

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Logger.type
case class Slf4jLogger(logger: Logger) extends Logger

Class to create a Logger based on Slf4j (simple logging facade for Java).

Class to create a Logger based on Slf4j (simple logging facade for Java).

Value parameters

logger

an instance of org.slf4j.Logger.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Logger
trait Flushable
trait AutoCloseable
class Object
trait Matchable
class Any
Show all
case class StringBuilderLogger(sb: StringBuilder) extends Logger

Class to represent a Logger which is based on a StringBuilder.

Class to represent a Logger which is based on a StringBuilder.

Value parameters

sb

an instance of StringBuilder.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Logger
trait Flushable
trait AutoCloseable
class Object
trait Matchable
class Any
Show all