Skip to content
This repository has been archived by the owner on Jun 19, 2019. It is now read-only.

Commit

Permalink
w3c: add configurablity whine on unregistered fields
Browse files Browse the repository at this point in the history
  • Loading branch information
eaceaser committed Oct 6, 2010
1 parent e6a95a7 commit 03cdfbb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/scala/com/twitter/ostrich/W3CStats.scala
Expand Up @@ -30,11 +30,10 @@ import java.text.SimpleDateFormat
*
* @param fields The fields, in order, as they will appear in the final w3c log output.
*/
class W3CStats(reporter: W3CReporter, fields: Array[String]) extends StatsProvider {
def this(logger: Logger, fields: Array[String]) = this(new W3CReporter(logger), fields)
class W3CStats(reporter: W3CReporter, fields: Array[String], complainAboutUnregisteredFields: Boolean) extends StatsProvider {
def this(logger: Logger, fields: Array[String]) = this(new W3CReporter(logger), fields, true)

val log = Logger.get(getClass.getName)
var complainAboutUnregisteredFields = true
val fieldNames: java.util.HashSet[String] = new java.util.HashSet()
fields.foreach { fieldNames.add(_) }

Expand Down Expand Up @@ -63,8 +62,9 @@ class W3CStats(reporter: W3CReporter, fields: Array[String]) extends StatsProvid
private def log_safe[T](name: String, value: T) {
if (complainAboutUnregisteredFields && !fieldNames.contains(name)) {
log.error("trying to log unregistered field: %s".format(name))
} else {
get + (name -> value)
}
get + (name -> value)
}

/**
Expand Down

0 comments on commit 03cdfbb

Please sign in to comment.