mirror of
https://github.com/denoland/deno.git
synced 2024-11-30 16:40:57 -05:00
fix format (#140)
This commit is contained in:
parent
0d2429cdf2
commit
61a3911be7
4 changed files with 21 additions and 27 deletions
|
@ -31,7 +31,7 @@ test(function parseDateTime() {
|
|||
test(function invalidParseDateTimeFormatThrows() {
|
||||
try {
|
||||
(datetime as any).parseDateTime("2019-01-01 00:00", "x-y-z");
|
||||
assert(false, 'no exception was thrown');
|
||||
assert(false, "no exception was thrown");
|
||||
} catch (e) {
|
||||
assertEqual(e.message, "Invalid datetime format!");
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ test(function parseDate() {
|
|||
test(function invalidParseDateFormatThrows() {
|
||||
try {
|
||||
(datetime as any).parseDate("2019-01-01", "x-y-z");
|
||||
assert(false, 'no exception was thrown');
|
||||
assert(false, "no exception was thrown");
|
||||
} catch (e) {
|
||||
assertEqual(e.message, "Invalid date format!");
|
||||
}
|
||||
|
|
|
@ -27,11 +27,7 @@ async function main() {
|
|||
await checkVersion();
|
||||
|
||||
const prettier = run({
|
||||
args: [
|
||||
"bash",
|
||||
"-c",
|
||||
"prettier --write *.ts */*.ts */**/*.ts *.md */*.md */**/*.md"
|
||||
]
|
||||
args: ["bash", "-c", "prettier --write '**/*.ts' '**/*.md'"]
|
||||
});
|
||||
const s = await prettier.status();
|
||||
exit(s.code);
|
||||
|
|
|
@ -32,7 +32,7 @@ export class BaseHandler {
|
|||
if (this.formatter instanceof Function) {
|
||||
return this.formatter(logRecord);
|
||||
}
|
||||
|
||||
|
||||
return this.formatter.replace(/{(\S+)}/g, (match, p1) => {
|
||||
const value = logRecord[p1];
|
||||
|
||||
|
@ -73,10 +73,7 @@ export class FileHandler extends WriterHandler {
|
|||
private _file: File;
|
||||
private _filename: string;
|
||||
|
||||
constructor(
|
||||
levelName: string,
|
||||
options: FileHandlerOptions,
|
||||
) {
|
||||
constructor(levelName: string, options: FileHandlerOptions) {
|
||||
super(levelName, options);
|
||||
this._filename = options.filename;
|
||||
}
|
||||
|
|
31
log/test.ts
31
log/test.ts
|
@ -32,15 +32,15 @@ test(function testDefaultlogMethods() {
|
|||
test(async function testDefaultFormatter() {
|
||||
await log.setup({
|
||||
handlers: {
|
||||
test: new TestHandler("DEBUG"),
|
||||
test: new TestHandler("DEBUG")
|
||||
},
|
||||
|
||||
loggers: {
|
||||
test: {
|
||||
level: "DEBUG",
|
||||
handlers: ["test"],
|
||||
},
|
||||
},
|
||||
handlers: ["test"]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const logger = log.getLogger("test");
|
||||
|
@ -53,16 +53,16 @@ test(async function testFormatterAsString() {
|
|||
await log.setup({
|
||||
handlers: {
|
||||
test: new TestHandler("DEBUG", {
|
||||
formatter: "test {levelName} {msg}",
|
||||
}),
|
||||
formatter: "test {levelName} {msg}"
|
||||
})
|
||||
},
|
||||
|
||||
loggers: {
|
||||
test: {
|
||||
level: "DEBUG",
|
||||
handlers: ["test"],
|
||||
},
|
||||
},
|
||||
handlers: ["test"]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const logger = log.getLogger("test");
|
||||
|
@ -75,20 +75,21 @@ test(async function testFormatterAsFunction() {
|
|||
await log.setup({
|
||||
handlers: {
|
||||
test: new TestHandler("DEBUG", {
|
||||
formatter: logRecord => `fn formmatter ${logRecord.levelName} ${logRecord.msg}`,
|
||||
}),
|
||||
formatter: logRecord =>
|
||||
`fn formmatter ${logRecord.levelName} ${logRecord.msg}`
|
||||
})
|
||||
},
|
||||
|
||||
loggers: {
|
||||
test: {
|
||||
level: "DEBUG",
|
||||
handlers: ["test"],
|
||||
},
|
||||
},
|
||||
handlers: ["test"]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const logger = log.getLogger("test");
|
||||
const handler = log.getHandler("test");
|
||||
logger.error("Hello, world!");
|
||||
assertEqual(handler.testOutput, "fn formmatter ERROR Hello, world!\n");
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue