From 5ba375e899ef82d7b276225bc9f6711d112dde74 Mon Sep 17 00:00:00 2001 From: Sami Vaarala Date: Mon, 17 Mar 2014 22:37:50 +0200 Subject: [PATCH] initial sparse documentation on logging --- website/guide/duktapebuiltins.html | 69 ++++++++++++++++++++++++++++++ website/guide/intro.html | 2 + 2 files changed, 71 insertions(+) diff --git a/website/guide/duktapebuiltins.html b/website/guide/duktapebuiltins.html index 4e98d8cb..ba1a7413 100644 --- a/website/guide/duktapebuiltins.html +++ b/website/guide/duktapebuiltins.html @@ -61,6 +61,7 @@ does not block.

BufferBuffer constructor (function). PointerPointer constructor (function). ThreadThread constructor (function). +LoggerLogger constructor (function). @@ -529,3 +530,71 @@ cases:

No properties at the moment. + +

Duktape.Logger (constructor)

+ + + + + + + + + + + +
PropertyDescription
prototypePrototype for Logger objects.
clogRepresentative logger for log entries written from C code.
+ +

Called as a constructor, creates a new Logger object with a specified name +(first argument). If the name is omitted, Logger will automatically assign +a name based on the calling function's fileName. +If called as a normal function, throws a TypeError.

+ +

Logger instances have the following properties:

+ + +

To write log entries:

+
+logger.info('three values:', val1, val2, val3);
+
+ +

For now, see the +internal documentation +on logging for more info.

+ +
+Tail calling might theoretically affect the automatic name assignment (i.e. +when logger name argument is omitted). However, constructor calls are never +converted to tail calls, so this is not a practical issue. +
+ +

Duktape.Logger.prototype

+ + + + + + + + + + + + + + + + + + + +
PropertyDescription
rawOutput a formatted log line, by default writes to stderr.
fmtFormat a single (object) argument.
traceWrite a trace level (level 0, TRC) log entry.
debugWrite a debug level (level 1, DBG) log entry.
infoWrite an info level (level 2, INF) log entry.
warnWrite a warn level (level 3, WRN) log entry.
errorWrite an error level (level 4, ERR) log entry.
fatalWrite a fatal level (level 5, FTL) log entry.
lDefault log level, initial value is 2 (info).
nDefault logger name, initial value is "anon".
diff --git a/website/guide/intro.html b/website/guide/intro.html index 6eae9f56..347b1be4 100644 --- a/website/guide/intro.html +++ b/website/guide/intro.html @@ -61,6 +61,8 @@ features (some are visible to applications, while others are internal):

  • Built-in Unicode support with no platform dependencies
  • Built-in number parsing and formatting with no platform dependencies
  • Additional custom JSON formats (JSONX and JSONC)
  • +
  • Very lightweight built-in logging framework available for both C and + Ecmascript code
  • Goals