@ -7,6 +7,7 @@
* /
Duktape . Logger . prototype . raw = function raw_replacement ( msg ) {
// Timestamp is non-predictable
msg = msg . replace ( /^\S+/ , 'TIMESTAMP' ) ;
print ( msg ) ;
}
@ -14,6 +15,11 @@ Duktape.Logger.prototype.raw = function raw_replacement(msg) {
/ * = = =
logger name
TIMESTAMP INF myLogger : logger created
TIMESTAMP INF anon : logger created
TIMESTAMP INF anon : undefined : inherit anon
TIMESTAMP INF anon : logger created
TIMESTAMP INF anon : null : inherit anon
TIMESTAMP INF input : logger created
TIMESTAMP INF myLogger : logger created
TIMESTAMP INF newName : logger renamed
TIMESTAMP INF anon : logger name deleted
@ -28,28 +34,31 @@ function loggerNameTest() {
logger = new Duktape . Logger ( 'myLogger' ) ;
logger . info ( 'logger created' ) ;
// Logger name defaults to caller fileName if present
// Logger name given as null/undefined (any non-string actually) causes
// the logger to not have a 'n' property and does *not* trigger automatic
// name assignment.
/ * X X X : t h i s w o u l d b e n i c e t o t e s t , b u t f i l e N a m e i s n o t w r i t a b l e s o
* expect string is difficult to control .
* /
/ *
function func2 ( ) {
return new Duktape . Logger ( ) ;
}
function func1 ( ) {
func1 . filename = 'fake.js' ;
var ret = func2 ( ) ;
return ret ;
}
logger = func1 ( ) ;
logger = new Duktape . Logger ( undefined ) ;
logger . info ( 'logger created' ) ;
logger . info ( 'undefined: inherit anon' ) ;
logger = new Duktape . Logger ( null ) ;
logger . info ( 'logger created' ) ;
logger . info ( 'null: inherit anon' ) ;
// Logger name defaults to caller fileName if present. We don't know
// the full path of the logger and fileName is not writable, so we use
// eval to force caller fileName to "input".
logger = eval ( 'new Duktape.Logger()' ) ; // caller fileName is 'input'
logger . info ( 'logger created' ) ;
* /
// If fileName is not present, logger gets no 'n' property and
// inherits 'n' from Logger prototype
/* XXX: same issue here */
/ * X X X : c a n n o t e a s i l y t e s t b e c a u s e c a n n o t c r e a t e a f u n c t i o n w i t h n o
* fileName , and fileName is not configurable so can ' t delete it .
* /
// Logger name can be modified runtime, and even removed in which
// case it is inherited from the Logger prototype