mirror of https://github.com/svaarala/duktape.git
Sami Vaarala
11 years ago
1 changed files with 34 additions and 0 deletions
@ -0,0 +1,34 @@ |
|||
/* |
|||
* Test that a logger created inside a module gets a reasonable default |
|||
* logger name. |
|||
*/ |
|||
|
|||
/*=== |
|||
Duktape.modSearch foo |
|||
TIMESTAMP INF foo: hello from module |
|||
Duktape.modSearch foo/BAR/quux |
|||
TIMESTAMP INF foo/BAR/quux: hello from module |
|||
===*/ |
|||
|
|||
function moduleLogNameTest() { |
|||
var mod; |
|||
|
|||
Duktape.modSearch = function (id) { |
|||
print('Duktape.modSearch', id); |
|||
return 'var logger = new Duktape.Logger(); logger.info("hello from module");'; |
|||
}; |
|||
Duktape.Logger.prototype.raw = function (buf) { |
|||
var str = String(buf); |
|||
str = str.replace(/^\S+/, 'TIMESTAMP'); |
|||
print(str); |
|||
}; |
|||
|
|||
mod = require('foo'); |
|||
mod = require('foo/./bar/../BAR/quux'); // foo/BAR/quux absolute
|
|||
} |
|||
|
|||
try { |
|||
moduleLogNameTest(); |
|||
} catch (e) { |
|||
print(e); |
|||
} |
Loading…
Reference in new issue