Skip to content

Commit

Permalink
Minor updates to docs (Applies to #133)
Browse files Browse the repository at this point in the history
  • Loading branch information
darkfrog26 committed Jan 12, 2021
1 parent 9e9896b commit 2bcb795
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 2 deletions.
3 changes: 3 additions & 0 deletions core/js/src/main/scala/scribe/JavaScriptConsole.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
18 changes: 18 additions & 0 deletions core/jvm/src/main/scala/scribe/handler/Overflow.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 3 additions & 0 deletions core/shared/src/main/scala/scribe/filter/Filter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 3 additions & 0 deletions core/shared/src/main/scala/scribe/filter/FilterBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions core/shared/src/main/scala/scribe/filter/FilterMatcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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('.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ class AbbreviateBlock(block: FormatBlock,
val value = block.format(record).plainText
new TextOutput(Abbreviator(value, maxLength, separator, removeEntries, abbreviateName))
}
}
}

0 comments on commit 2bcb795

Please # to comment.