From 2bcb7958c33c0084f3be7beb0b093d31c315a155 Mon Sep 17 00:00:00 2001 From: Matt Hicks Date: Mon, 11 Jan 2021 16:27:41 -0800 Subject: [PATCH] Minor updates to docs (Applies to #133) --- .../main/scala/scribe/JavaScriptConsole.scala | 3 +++ .../format/RichBrowserOutputFormat.scala | 6 +++++- .../scribe/writer/BrowserConsoleWriter.scala | 3 +++ .../handler/AsynchronousLogHandler.scala | 13 +++++++++++++ .../main/scala/scribe/handler/Overflow.scala | 18 ++++++++++++++++++ .../scala/scribe/filter/ClassNameFilter.scala | 3 +++ .../src/main/scala/scribe/filter/Filter.scala | 3 +++ .../scala/scribe/filter/FilterBuilder.scala | 3 +++ .../scala/scribe/filter/FilterMatcher.scala | 3 +++ .../scribe/filter/PackageNameFilter.scala | 3 +++ .../scala/scribe/format/AbbreviateBlock.scala | 2 +- 11 files changed, 58 insertions(+), 2 deletions(-) diff --git a/core/js/src/main/scala/scribe/JavaScriptConsole.scala b/core/js/src/main/scala/scribe/JavaScriptConsole.scala index 8f38959e3..68148d8c4 100644 --- a/core/js/src/main/scala/scribe/JavaScriptConsole.scala +++ b/core/js/src/main/scala/scribe/JavaScriptConsole.scala @@ -2,6 +2,9 @@ package scribe import scala.scalajs.js +/** + * Facade around extra features of the JavaScript console in the browser + */ @js.native trait JavaScriptConsole extends js.Object { diff --git a/core/js/src/main/scala/scribe/output/format/RichBrowserOutputFormat.scala b/core/js/src/main/scala/scribe/output/format/RichBrowserOutputFormat.scala index d2ae43ba1..b98fe828d 100644 --- a/core/js/src/main/scala/scribe/output/format/RichBrowserOutputFormat.scala +++ b/core/js/src/main/scala/scribe/output/format/RichBrowserOutputFormat.scala @@ -1,9 +1,13 @@ package scribe.output.format -import scribe.output.{BackgroundColoredOutput, BoldOutput, Color, ColoredOutput, CompositeOutput, ItalicOutput, LogOutput, StrikethroughOutput, TextOutput, URLOutput, UnderlineOutput} + +import scribe.output._ import scribe.writer.BrowserConsoleWriter import scala.collection.mutable.ListBuffer +/** + * Supports rich output to JavaScript console in the browser + */ object RichBrowserOutputFormat extends OutputFormat { override def apply(output: LogOutput, stream: String => Unit): Unit = recurse( stream = stream, diff --git a/core/js/src/main/scala/scribe/writer/BrowserConsoleWriter.scala b/core/js/src/main/scala/scribe/writer/BrowserConsoleWriter.scala index 813310040..2d92fc92b 100644 --- a/core/js/src/main/scala/scribe/writer/BrowserConsoleWriter.scala +++ b/core/js/src/main/scala/scribe/writer/BrowserConsoleWriter.scala @@ -8,6 +8,9 @@ import scribe.output.format.OutputFormat import scala.collection.mutable.ListBuffer import scala.scalajs.js +/** + * Writer specifically to target the JavaScript console in the browser + */ object BrowserConsoleWriter extends Writer { val args: ListBuffer[String] = ListBuffer.empty diff --git a/core/jvm/src/main/scala/scribe/handler/AsynchronousLogHandler.scala b/core/jvm/src/main/scala/scribe/handler/AsynchronousLogHandler.scala index 1a42bba04..ab454f62d 100644 --- a/core/jvm/src/main/scala/scribe/handler/AsynchronousLogHandler.scala +++ b/core/jvm/src/main/scala/scribe/handler/AsynchronousLogHandler.scala @@ -11,6 +11,16 @@ import scribe.writer.{ConsoleWriter, Writer} import scala.language.implicitConversions +/** + * Provides support for asynchronous logging to process the log record in another thread and avoid any blocking. + * + * @param formatter the formatter to use (defaults to Formatter.default) + * @param writer the writer to use (defaults to ConsoleWriter) + * @param outputFormat the output format to use (defaults to OutputFormat.default) + * @param modifiers the modifiers + * @param maxBuffer the maximum buffer before overflow occurs (defaults to AsynchronousLogHandler.DefaultMaxBuffer) + * @param overflow what to do with overflows (defaults to DropOld) + */ case class AsynchronousLogHandler(formatter: Formatter = Formatter.default, writer: Writer = ConsoleWriter, outputFormat: OutputFormat = OutputFormat.default, @@ -75,5 +85,8 @@ case class AsynchronousLogHandler(formatter: Formatter = Formatter.default, } object AsynchronousLogHandler { + /** + * The default max buffer of log records (set to 1000) + */ val DefaultMaxBuffer: Int = 1000 } \ No newline at end of file diff --git a/core/jvm/src/main/scala/scribe/handler/Overflow.scala b/core/jvm/src/main/scala/scribe/handler/Overflow.scala index a642f03f1..8bf2b17b3 100644 --- a/core/jvm/src/main/scala/scribe/handler/Overflow.scala +++ b/core/jvm/src/main/scala/scribe/handler/Overflow.scala @@ -2,9 +2,27 @@ package scribe.handler sealed trait Overflow +/** + * Overflow instructions for AsynchronousLogHandler + */ object Overflow { + /** + * Drops oldest over max buffer + */ case object DropOld extends Overflow + + /** + * Drops the new messages + */ case object DropNew extends Overflow + + /** + * Blocks until the buffer falls below max + */ case object Block extends Overflow + + /** + * Throws an exception if the buffer overflows + */ case object Error extends Overflow } \ No newline at end of file diff --git a/core/shared/src/main/scala/scribe/filter/ClassNameFilter.scala b/core/shared/src/main/scala/scribe/filter/ClassNameFilter.scala index ee902723b..aa9414b2f 100644 --- a/core/shared/src/main/scala/scribe/filter/ClassNameFilter.scala +++ b/core/shared/src/main/scala/scribe/filter/ClassNameFilter.scala @@ -2,6 +2,9 @@ package scribe.filter import scribe.LogRecord +/** + * Filter matcher based on the class name + */ object ClassNameFilter extends FilterMatcher { override protected def string[M](record: LogRecord[M]): String = record.className } \ No newline at end of file diff --git a/core/shared/src/main/scala/scribe/filter/Filter.scala b/core/shared/src/main/scala/scribe/filter/Filter.scala index 3fedcd681..64a1b9bca 100644 --- a/core/shared/src/main/scala/scribe/filter/Filter.scala +++ b/core/shared/src/main/scala/scribe/filter/Filter.scala @@ -2,6 +2,9 @@ package scribe.filter import scribe.LogRecord +/** + * Filter for use in FilterBuilder, which is a LogModifier + */ trait Filter { def matches[M](record: LogRecord[M]): Boolean } \ No newline at end of file diff --git a/core/shared/src/main/scala/scribe/filter/FilterBuilder.scala b/core/shared/src/main/scala/scribe/filter/FilterBuilder.scala index 5eeb0ab5c..b4b5bd244 100644 --- a/core/shared/src/main/scala/scribe/filter/FilterBuilder.scala +++ b/core/shared/src/main/scala/scribe/filter/FilterBuilder.scala @@ -3,6 +3,9 @@ package scribe.filter import scribe.modify.LogModifier import scribe.{Level, LogRecord, Priority} +/** + * FilterBuilder allows convenient log modification + */ case class FilterBuilder(priority: Priority = Priority.Normal, select: List[Filter] = Nil, include: List[Filter] = Nil, diff --git a/core/shared/src/main/scala/scribe/filter/FilterMatcher.scala b/core/shared/src/main/scala/scribe/filter/FilterMatcher.scala index dd96051a3..dcd090235 100644 --- a/core/shared/src/main/scala/scribe/filter/FilterMatcher.scala +++ b/core/shared/src/main/scala/scribe/filter/FilterMatcher.scala @@ -2,6 +2,9 @@ package scribe.filter import scribe.LogRecord +/** + * Matcher for use with filters + */ trait FilterMatcher { protected def string[M](record: LogRecord[M]): String diff --git a/core/shared/src/main/scala/scribe/filter/PackageNameFilter.scala b/core/shared/src/main/scala/scribe/filter/PackageNameFilter.scala index 1abf2da91..b11ba5d9f 100644 --- a/core/shared/src/main/scala/scribe/filter/PackageNameFilter.scala +++ b/core/shared/src/main/scala/scribe/filter/PackageNameFilter.scala @@ -2,6 +2,9 @@ package scribe.filter import scribe.LogRecord +/** + * Filters based on the package name + */ object PackageNameFilter extends FilterMatcher { override protected def string[M](record: LogRecord[M]): String = { val index = record.className.lastIndexOf('.') diff --git a/core/shared/src/main/scala/scribe/format/AbbreviateBlock.scala b/core/shared/src/main/scala/scribe/format/AbbreviateBlock.scala index 243a1f3d8..047daf66e 100644 --- a/core/shared/src/main/scala/scribe/format/AbbreviateBlock.scala +++ b/core/shared/src/main/scala/scribe/format/AbbreviateBlock.scala @@ -13,4 +13,4 @@ class AbbreviateBlock(block: FormatBlock, val value = block.format(record).plainText new TextOutput(Abbreviator(value, maxLength, separator, removeEntries, abbreviateName)) } -} +} \ No newline at end of file