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
Members list
Value members
Concrete methods
Close this Flog. For standard slf4j loggers, this does nothing. However, for Appendable loggers, this call will typically flush and close the appendable instance.
Close this Flog. For standard slf4j loggers, this does nothing. However, for Appendable loggers, this call will typically flush and close the appendable instance.
Attributes
Use this method to create a new Flog with logging disabled.
Use this method to create a new Flog with logging disabled.
Attributes
- Returns
-
a new instance of Flog.
Method to capture any text held by this Flog. In the case of a "standard" slf4j logger, the returned value will is undefined.
Method to capture any text held by this Flog. In the case of a "standard" slf4j logger, the returned value will is undefined.
Attributes
- Returns
-
the value of logger.toString.
- Definition Classes
-
Any
Use this method to create a new Flog based on the given logging function.
Use this method to create a new Flog based on the given logging function.
Value parameters
- logger
-
an instance of LogFunction.
Attributes
- Returns
-
a new instance of Flog.
Inherited methods
Backstop method to yield a String from a T. NOTE: use this when you need a Loggable to log a container which includes an unsupported type.
Backstop method to yield a String from a T. NOTE: use this when you need a Loggable to log a container which includes an unsupported type.
Type parameters
- T
-
the type of t.
Attributes
- Returns
-
a Loggable[T] which uses toString.
- Inherited from:
- Loggables
Method to return a Loggable[ Either[L, R] ].
Method to return a Loggable[ Either[L, R] ].
Type parameters
- L
-
the "left" type of any Either which is to be logged.
- R
-
the "right" type of any Either which is to be logged.
Attributes
- Returns
-
a Loggable[ Either[L, R] ].
- Inherited from:
- Loggables
Method to create a Loggable of an Iterable[T]. The elements of the result are then logged utilizing the !! method.
Method to create a Loggable of an Iterable[T]. The elements of the result are then logged utilizing the !! method.
Type parameters
- T
-
the underlying type of the elements to be logged. Must provide evidence of Loggable[T].
Value parameters
- atLeast
-
the minimum number of elements to show in the log message before the ellipsis section starts.
- bookends
-
(optional) a String of length two specifying the first and last characters of the resulting String for a given Iterable. Defaults to "[]".
Attributes
- Returns
-
Loggable[ Iterable[T] ].
- Inherited from:
- Loggables
This method creates a Loggable instance which works for a tuple (a K-V pair). It is an alternative to loggable2 but that method names the members whereas we don't want them named here.
This method creates a Loggable instance which works for a tuple (a K-V pair). It is an alternative to loggable2 but that method names the members whereas we don't want them named here.
Type parameters
- K
-
the key type.
- V
-
the value type.
Attributes
- Returns
-
a Loggable[(K, V)].
- Inherited from:
- Loggables
Method to return a Loggable[T] where T is a 1-ary Product and which is based on a function to convert a P0 into a T.
Method to return a Loggable[T] where T is a 1-ary Product and which is based on a function to convert a P0 into a T.
NOTE: be careful using this particular method it only applies where T is a 1-tuple (e.g. a case class with one field -- not common). It probably shouldn't ever be used in practice. It can cause strange initialization errors!
Type parameters
- P0
-
the type of the (single) field of the Product type T.
- T
-
the underlying type of the first parameter of the input to the render method.
Value parameters
- construct
-
a function P0 => T, usually the apply method of a case class. The sole purpose of this function is for type inference--it is never actually invoked.
- fields
-
(optional parameter) an explicit list of one field name.
Attributes
- Returns
-
a Loggable[T].
- Inherited from:
- Loggables
Method to return a Loggable[T] where T is a 2-ary Product and which is based on a function to convert a (P0, P1) into a T.
Method to return a Loggable[T] where T is a 2-ary Product and which is based on a function to convert a (P0, P1) into a T.
Type parameters
- P0
-
the type of the first field of the Product type T.
- P1
-
the type of the second field of the Product type T.
- T
-
the underlying type of the first parameter of the input to the render method.
Value parameters
- construct
-
a function (P0, P1) => T, usually the apply method of a case class. The sole purpose of this function is for type inference--it is never actually invoked.
- fields
-
(optional parameter) an explicit list of 2 field names.
Attributes
- Returns
-
a Loggable[T].
- Inherited from:
- Loggables
Method to return a Loggable[T] where T is a 3-ary Product and which is based on a function to convert a (P0, P1, P2) into a T.
Method to return a Loggable[T] where T is a 3-ary Product and which is based on a function to convert a (P0, P1, P2) into a T.
Type parameters
- P0
-
the type of the first field of the Product type T.
- P1
-
the type of the second field of the Product type T.
- P2
-
the type of the third field of the Product type T.
- T
-
the underlying type of the first parameter of the input to the render method.
Value parameters
- construct
-
a function (P0, P1, P2) => T, usually the apply method of a case class. The sole purpose of this function is for type inference--it is never actually invoked.
- fields
-
(optional parameter) an explicit list of 3 field names.
Attributes
- Returns
-
a Loggable[T].
- Inherited from:
- Loggables
Method to return a Loggable[T] where T is a 4-ary Product and which is based on a function to convert a (P0, P1, P2, P3) into a T.
Method to return a Loggable[T] where T is a 4-ary Product and which is based on a function to convert a (P0, P1, P2, P3) into a T.
Type parameters
- P0
-
the type of the first field of the Product type T.
- P1
-
the type of the second field of the Product type T.
- P2
-
the type of the third field of the Product type T.
- P3
-
the type of the fourth field of the Product type T.
- T
-
the underlying type of the first parameter of the input to the render method.
Value parameters
- construct
-
a function (P0, P1, P2, P3) => T, usually the apply method of a case class. The sole purpose of this function is for type inference--it is never actually invoked.
- fields
-
(optional parameter) an explicit list of 4 field names.
Attributes
- Returns
-
a Loggable[T].
- Inherited from:
- Loggables
Method to return a Loggable[T] where T is a 5-ary Product and which is based on a function to convert a (P0, P1, P2, P3, P4) into a T.
Method to return a Loggable[T] where T is a 5-ary Product and which is based on a function to convert a (P0, P1, P2, P3, P4) into a T.
Type parameters
- P0
-
the type of the first field of the Product type T.
- P1
-
the type of the second field of the Product type T.
- P2
-
the type of the third field of the Product type T.
- P3
-
the type of the fourth field of the Product type T.
- P4
-
the type of the fifth field of the Product type T.
- T
-
the underlying type of the first parameter of the input to the render method.
Value parameters
- construct
-
a function (P0, P1, P2, P3, P4) => T, usually the apply method of a case class. The sole purpose of this function is for type inference--it is never actually invoked.
- fields
-
(optional parameter) an explicit list of 5 field names.
Attributes
- Returns
-
a Loggable[T].
- Inherited from:
- Loggables
Method to return a Loggable[T] where T is a 6-ary Product and which is based on a function to convert a (P0, P1, P2, P3, P4, P5) into a T.
Method to return a Loggable[T] where T is a 6-ary Product and which is based on a function to convert a (P0, P1, P2, P3, P4, P5) into a T.
Type parameters
- P0
-
the type of the first field of the Product type T.
- P1
-
the type of the second field of the Product type T.
- P2
-
the type of the third field of the Product type T.
- P3
-
the type of the fourth field of the Product type T.
- P4
-
the type of the fifth field of the Product type T.
- P5
-
the type of the sixth field of the Product type T.
- T
-
the underlying type of the first parameter of the input to the render method.
Value parameters
- construct
-
a function (P0, P1, P2, P3, P4, P5) => T, usually the apply method of a case class. The sole purpose of this function is for type inference--it is never actually invoked.
- fields
-
(optional parameter) an explicit list of 6 field names.
Attributes
- Returns
-
a Loggable[T].
- Inherited from:
- Loggables
Method to return a Loggable[T] where T is a 7-ary Product and which is based on a function to convert a (P0, P1, P2, P3, P4, P5, P6) into a T.
Method to return a Loggable[T] where T is a 7-ary Product and which is based on a function to convert a (P0, P1, P2, P3, P4, P5, P6) into a T.
Type parameters
- P0
-
the type of the first field of the Product type T.
- P1
-
the type of the second field of the Product type T.
- P2
-
the type of the third field of the Product type T.
- P3
-
the type of the fourth field of the Product type T.
- P4
-
the type of the fifth field of the Product type T.
- P5
-
the type of the sixth field of the Product type T.
- P6
-
the type of the seventh field of the Product type T.
- T
-
the underlying type of the first parameter of the input to the render method.
Value parameters
- construct
-
a function (P0, P1, P2, P3, P4, P5, P6) => T, usually the apply method of a case class. The sole purpose of this function is for type inference--it is never actually invoked.
- fields
-
(optional parameter) an explicit list of 7 field names.
Attributes
- Returns
-
a Loggable[T].
- Inherited from:
- Loggables
Method to return a Loggable[T] where T is a 8-ary Product and which is based on a function to convert a (P0, P1, P2, P3, P4, P5, P6, P7) into a T.
Method to return a Loggable[T] where T is a 8-ary Product and which is based on a function to convert a (P0, P1, P2, P3, P4, P5, P6, P7) into a T.
Type parameters
- P0
-
the type of the first field of the Product type T.
- P1
-
the type of the second field of the Product type T.
- P2
-
the type of the third field of the Product type T.
- P3
-
the type of the fourth field of the Product type T.
- P4
-
the type of the fifth field of the Product type T.
- P5
-
the type of the sixth field of the Product type T.
- P6
-
the type of the seventh field of the Product type T.
- P7
-
the type of the eighth field of the Product type T.
- T
-
the underlying type of the first parameter of the input to the render method.
Value parameters
- construct
-
a function (P0, P1, P2, P3, P4, P5, P6, P7) => T, usually the apply method of a case class. The sole purpose of this function is for type inference--it is never actually invoked.
- fields
-
(optional parameter) an explicit list of 8 field names.
Attributes
- Returns
-
a Loggable[T].
- Inherited from:
- Loggables
Method to return a Loggable[T] where T is a 9-ary Product and which is based on a function to convert a (P0, P1, P2, P3, P4, P5, P6, P7, P8) into a T.
Method to return a Loggable[T] where T is a 9-ary Product and which is based on a function to convert a (P0, P1, P2, P3, P4, P5, P6, P7, P8) into a T.
Type parameters
- P0
-
the type of the first field of the Product type T.
- P1
-
the type of the second field of the Product type T.
- P2
-
the type of the third field of the Product type T.
- P3
-
the type of the fourth field of the Product type T.
- P4
-
the type of the fifth field of the Product type T.
- P5
-
the type of the sixth field of the Product type T.
- P6
-
the type of the seventh field of the Product type T.
- P7
-
the type of the eighth field of the Product type T.
- P8
-
the type of the ninth field of the Product type T.
- T
-
the underlying type of the first parameter of the input to the render method.
Value parameters
- construct
-
a function (P0, P1, P2, P3, P4, P5, P6, P7, P8) => T, usually the apply method of a case class. The sole purpose of this function is for type inference--it is never actually invoked.
- fields
-
(optional parameter) an explicit list of 9 field names.
Attributes
- Returns
-
a Loggable[T].
- Inherited from:
- Loggables
Method to return a Loggable[ Map[K, T] ].
Method to return a Loggable[ Map[K, T] ].
NOTE: unless the Map (passed as the bound variable) is a SeqMap, the order of the key-value pairs is undefined.
Type parameters
- K
-
the type of the keys.
- T
-
the underlying type of the values.
Value parameters
- bookends
-
(optional) a String of length two specifying the first and last characters of the resulting String for a given Map. Defaults to "{}".
Attributes
- Returns
-
a Loggable[ Map[K, T] ]
- Inherited from:
- Loggables
Method to return a Loggable[ Option[T] ].
Method to return a Loggable[ Option[T] ].
Type parameters
- T
-
the underlying type of the first parameter of the input to the render method.
Attributes
- Returns
-
a Loggable[ Option[T] ].
- Inherited from:
- Loggables
Attributes
- Inherited from:
- Product
Attributes
- Inherited from:
- Product
TESTME
TESTME
Method which maps an Iterable of X with a function to an Iterable of Try[Y]. The elements of the result are then logged utilizing the !! method. NOTE that the returned value will only include the successful elements.
Type parameters
- X
-
the underlying type of xs.
- Y
-
the underlying type of the intermediate type (must be Loggable).
Value parameters
- f
-
a function X => Try[Y].
Attributes
- Returns
-
an Iterable of Try[Y] such that all the failures have been logged but not included in the result.
- Inherited from:
- Loggables
Method to return a Loggable[ Try[T] ].
Method to return a Loggable[ Try[T] ].
Type parameters
- T
-
the underlying type of the first parameter of the input to the render method.
Attributes
- Returns
-
a Loggable[ Try[T] ].
- Inherited from:
- Loggables
Extensions
Extensions
Method to generate an INFO-level log entry for a (Loggable) value of X. Logging is performed as a side effect. Rendering of the x value is via the toLog method of the implicit Loggable[X].
Method to generate an INFO-level log entry for a (Loggable) value of X. Logging is performed as a side effect. Rendering of the x value is via the toLog method of the implicit Loggable[X].
Type parameters
- X
-
the type of x, which must provide implicit evidence of being Loggable.
Value parameters
- x
-
the value to be logged.
Attributes
- Returns
-
the value of x.
Method to generate an info log entry for an Iterable of a (Loggable) X. Logging is performed as a side effect. Rendering of the x value is via the toLog method of the implicit Loggable[X].
Method to generate an info log entry for an Iterable of a (Loggable) X. Logging is performed as a side effect. Rendering of the x value is via the toLog method of the implicit Loggable[X].
Type parameters
- X
-
the underlying type of xs, which must provide implicit evidence of being Loggable.
Value parameters
- xs
-
the Iterable value to be logged.
Attributes
- Returns
-
the value of x.
Method to generate an info log entry for an Iterator of a (Loggable) X. Logging is performed as a side effect. Rendering of the x value is via the logIterable method.
Method to generate an info log entry for an Iterator of a (Loggable) X. Logging is performed as a side effect. Rendering of the x value is via the logIterable method.
Type parameters
- X
-
the underlying type of xs, which must provide implicit evidence of being Loggable.
Value parameters
- xs
-
the Iterator value to be logged.
Attributes
- Returns
-
the value of x.
Method to generate an info log entry for an Option of a (Loggable) X. Logging is performed as a side effect. Rendering of the x value is via the toLog method of the implicit Loggable[X].
Method to generate an info log entry for an Option of a (Loggable) X. Logging is performed as a side effect. Rendering of the x value is via the toLog method of the implicit Loggable[X].
Type parameters
- X
-
the underlying type of x, which must provide implicit evidence of being Loggable.
Value parameters
- xo
-
the optional value to be logged.
Attributes
- Returns
-
the value of x.
Method to generate an info log entry for a Map[K, V]. Logging is performed as a side effect.
Method to generate an info log entry for a Map[K, V]. Logging is performed as a side effect.
Type parameters
- K
-
the type of the map keys, which must provide implicit evidence of being Loggable.
- V
-
the type of the map values, which must provide implicit evidence of being Loggable.
Value parameters
- kVm
-
the Map to be logged.
Attributes
- Returns
-
the value of x.
Method to generate an info log entry for a Future[X]. Logging is performed as a side effect.
Method to generate an info log entry for a Future[X]. Logging is performed as a side effect.
Type parameters
- X
-
the underlying type of the given input.
Value parameters
- xf
-
the future value to be logged.
Attributes
- Returns
-
the value of xf.
Method to log the value xy (a Try[X]) but which logs any failures using the errorFunction rather than the loggerFunction. NOTE that the returned value, if xy is a Failure, is not exactly the same as xy.
Method to log the value xy (a Try[X]) but which logs any failures using the errorFunction rather than the loggerFunction. NOTE that the returned value, if xy is a Failure, is not exactly the same as xy.
Type parameters
- X
-
the underlying type of xy.
Value parameters
- xy
-
an instance of Try[X].
Attributes
- Returns
-
if xy is successful, then xy, otherwise if Failure(e) then Failure(LoggedException(e)).
Method to generate a DEBUG-level log entry for a (Loggable) value of X. Logging is performed as a side effect. Rendering of the x value is via the toLog method of the implicit Loggable[X].
Method to generate a DEBUG-level log entry for a (Loggable) value of X. Logging is performed as a side effect. Rendering of the x value is via the toLog method of the implicit Loggable[X].
Type parameters
- X
-
the type of x, which must provide implicit evidence of being Loggable.
Value parameters
- x
-
the value to be logged.
Attributes
- Returns
-
the value of x.
Method to generate a debug log entry for an Iterable of a (Loggable) X. Logging is performed as a side effect. Rendering of the x value is via the toLog method of the implicit Loggable[X].
Method to generate a debug log entry for an Iterable of a (Loggable) X. Logging is performed as a side effect. Rendering of the x value is via the toLog method of the implicit Loggable[X].
Type parameters
- X
-
the underlying type of x, which must provide implicit evidence of being Loggable.
Value parameters
- xs
-
the Iterable value to be logged.
Attributes
- Returns
-
the value of x.
Method to generate a debug log entry for an Option of a (Loggable) X. Logging is performed as a side effect. Rendering of the x value is via the toLog method of the implicit Loggable[X].
Method to generate a debug log entry for an Option of a (Loggable) X. Logging is performed as a side effect. Rendering of the x value is via the toLog method of the implicit Loggable[X].
Type parameters
- X
-
the underlying type of x, which must provide implicit evidence of being Loggable.
Value parameters
- xo
-
the optional value to be logged.
Attributes
- Returns
-
the value of x.
Method to generate a trace log entry for a Map[K, V]. Logging is performed as a side effect.
Method to generate a trace log entry for a Map[K, V]. Logging is performed as a side effect.
Type parameters
- K
-
the type of the map keys, which must provide implicit evidence of being Loggable.
- V
-
the type of the map values, which must provide implicit evidence of being Loggable.
Value parameters
- kVm
-
the Map to be logged.
Attributes
- Returns
-
the value of x.
Method to generate an debug log entry for a Future[X]. Logging is performed as a side effect.
Method to generate an debug log entry for a Future[X]. Logging is performed as a side effect.
Type parameters
- X
-
the underlying type of the given input.
Value parameters
- xf
-
the future value to be logged.
Attributes
- Returns
-
the value of xf.
Method to generate a TRACE-level log entry for a (Loggable) value of X. Logging is performed as a side effect. Rendering of the x value is via the toLog method of the implicit Loggable[X].
Method to generate a TRACE-level log entry for a (Loggable) value of X. Logging is performed as a side effect. Rendering of the x value is via the toLog method of the implicit Loggable[X].
Type parameters
- X
-
the type of x, which must provide implicit evidence of being Loggable.
Value parameters
- x
-
the value to be logged.
Attributes
- Returns
-
the value of x.
Method to generate a trace log entry for an Iterable of a (Loggable) X. Logging is performed as a side effect. Rendering of the x value is via the toLog method of the implicit Loggable[X].
Method to generate a trace log entry for an Iterable of a (Loggable) X. Logging is performed as a side effect. Rendering of the x value is via the toLog method of the implicit Loggable[X].
Type parameters
- X
-
the underlying type of x, which must provide implicit evidence of being Loggable.
Value parameters
- xs
-
the Iterable value to be logged.
Attributes
- Returns
-
the value of x.
Method to generate a trace log entry for an Option of a (Loggable) X. Logging is performed as a side effect. Rendering of the x value is via the toLog method of the implicit Loggable[X].
Method to generate a trace log entry for an Option of a (Loggable) X. Logging is performed as a side effect. Rendering of the x value is via the toLog method of the implicit Loggable[X].
Type parameters
- X
-
the underlying type of x, which must provide implicit evidence of being Loggable.
Value parameters
- xo
-
the optional value to be logged.
Attributes
- Returns
-
the value of x.
Method to generate a debug log entry for a Map[K, V]. Logging is performed as a side effect.
Method to generate a debug log entry for a Map[K, V]. Logging is performed as a side effect.
Type parameters
- K
-
the type of the map keys, which must provide implicit evidence of being Loggable.
- V
-
the type of the map values, which must provide implicit evidence of being Loggable.
Value parameters
- kVm
-
the Map to be logged.
Attributes
- Returns
-
the value of x.
Method to generate a trace log entry for a Future[X]. Logging is performed as a side effect.
Method to generate a trace log entry for a Future[X]. Logging is performed as a side effect.
Type parameters
- X
-
the underlying type of the given input.
Value parameters
- xf
-
the future value to be logged.
Attributes
- Returns
-
the value of xf.
Method to generate a log entry for a type which is not itself Loggable. Logging is performed as a side effect. Rendering of the x value is via the toString method.
Method to generate a log entry for a type which is not itself Loggable. Logging is performed as a side effect. Rendering of the x value is via the toString method.
This !| method will be deprecated soon as Loggable is now contravariant in T and there is an implicit def loggableAny[T] which is available.
Type parameters
- X
-
the type of x.
Value parameters
- x
-
the value to be logged.
Attributes
- Returns
-
the value of x.
Synonym for: def !?[X: Loggable](x: => X): X.
Synonym for: def !?[X: Loggable](x: => X): X.
Method to generate a DEBUG-level log entry for a (Loggable) value of X. Logging is performed as a side effect. Rendering of the x value is via the toLog method of the implicit Loggable[X].
Type parameters
- X
-
the type of x, which must provide implicit evidence of being Loggable.
Value parameters
- x
-
the value to be logged.
Attributes
- Returns
-
the value of x.
Method to generate an ERROR-level log entry for a (Loggable) value of X. Logging is performed as a side effect. Rendering of the x value is via the toLog method of the implicit Loggable[X].
Method to generate an ERROR-level log entry for a (Loggable) value of X. Logging is performed as a side effect. Rendering of the x value is via the toLog method of the implicit Loggable[X].
NOTE: there is a null coded here for the default value of t. It's justified because it is simply following the Java calling convention.
Type parameters
- X
-
the type of x, which must provide implicit evidence of being Loggable.
Value parameters
- t
-
a Throwable (defaults to null) -- but don't forget the empty parentheses in that case.
- x
-
the value to be logged.
Attributes
- Returns
-
the value of x.
Synonym for: def !: X
Synonym for: def !: X
Method to generate an INFO-level log entry for a (Loggable) value of X. Logging is performed as a side effect. Rendering of the x value is via the toLog method of the implicit Loggable[X].
Type parameters
- X
-
the type of x, which must provide implicit evidence of being Loggable.
Value parameters
- x
-
the value to be logged.
Attributes
- Returns
-
the value of x.
Synonym for: def !??[X: Loggable](x: => X): X
Synonym for: def !??[X: Loggable](x: => X): X
Method to generate a TRACE-level log entry for a (Loggable) value of X. Logging is performed as a side effect. Rendering of the x value is via the toLog method of the implicit Loggable[X].
Type parameters
- X
-
the type of x, which must provide implicit evidence of being Loggable.
Value parameters
- x
-
the value to be logged.
Attributes
- Returns
-
the value of x.
Method to generate a WARN-level log entry for a (Loggable) value of X. Logging is performed as a side effect. Rendering of the x value is via the toLog method of the implicit Loggable[X].
Method to generate a WARN-level log entry for a (Loggable) value of X. Logging is performed as a side effect. Rendering of the x value is via the toLog method of the implicit Loggable[X].
Type parameters
- X
-
the type of x, which must provide implicit evidence of being Loggable.
Value parameters
- x
-
the value to be logged.
Attributes
- Returns
-
the value of x.
Method to simply return the value of x without any logging.
Method to simply return the value of x without any logging.
Type parameters
- X
-
the type of x.
Value parameters
- x
-
the value.
Attributes
- Returns
-
the value of x.