本文整理匯總了TypeScript中Logger.Logger類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Logger類的具體用法?TypeScript Logger怎麽用?TypeScript Logger使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Logger類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
app.use((err, req, res, next) => {
Logger.info(err.stack);
res.status(500).send({
"status": "internal error",
"message": err.stack,
});
});
示例2: constructor
constructor( private logger: Logger ) {
this.logs = logger.allLogs();
}
示例3: express
import * as morgan from "morgan";
import * as Config from "config";
import { getInstance } from "./inversify.config";
import { Logger } from "logger";
import { IAPI } from "./api/IAPI";
let app: any = express(),
api: IAPI = getInstance<IAPI>("IAPI"),
loggerConfig: any = Config.get("logger"),
dbConfig: any = Config.get("mongodb"),
mongodb: Mongodb;
/**
* Initialize Logger
*/
Logger.init(loggerConfig);
/**
* Initialize Mongodb
*/
mongodb = new Mongodb(dbConfig);
mongodb.connect(
(error) => {
Logger.log(error);
}, () => {
Logger.log("Connected");
}
);
/** If the Node process ends, close the Mongoose connection */
process.on("SIGINT", () => {
示例4: function
Mongoose.connection.on("disconnected", function() {
Logger.info("Mongoose default connection disconnected");
});
示例5:
Mongoose.disconnect((err) => {
Logger.info(err);
});
示例6: toggleTodo
toggleTodo() {
this.todo.checked = !this.todo.checked;
this.logger.info( `'${this.todo.title}' ${this.todo.checked ? 'checked' : 'unchecked'}` );
}