【发布时间】:2020-02-10 20:11:54
【问题描述】:
我在 nodejs 中有两个文件:
index.jsfunction.js
index.js 是我的主文件,我在其中调用function.js 中的函数。在function.js我需要使用日志,问题是我没有弄清楚如何使用它。
function.js
module.exports = {
Exemplfunciton: async () => {
app.log('#### This is just an exemple im trying to run')
}
checkCalcul:async(a,b) = > {
log.(`The Val of A : ${a}, the Val of B: ${b}`
return a+b
}
}
index.js
const functionToCall = require('/function.js)
module.exports = app => {
functionToCall.Exemplfunciton()
functionToCall.checkCalcul(4,5)
}
会回来
应用未定义
在它返回给我的 function.js 中没有应用程序的情况下尝试过
未定义日志。
我只需要在函数之间使用app.log(我主要的是index.js和function.js)
【问题讨论】:
标签: javascript node.js logging