Added logs for testing

This commit is contained in:
emad-salah 2020-02-18 00:38:07 +01:00
parent 38dabe850b
commit c3ac6dbc28

View file

@ -89,26 +89,31 @@ module.exports = async (
}); });
const checkHealth = async () => { const checkHealth = async () => {
logger.info("Getting service status...")
const serviceStatus = await getAvailableService(); const serviceStatus = await getAvailableService();
logger.info("Received status:", serviceStatus);
const LNDStatus = serviceStatus; const LNDStatus = serviceStatus;
try { try {
logger.info("Getting API status...");
const APIHealth = await Http.get(`${usetls ? 'https' : 'http'}://localhost:${serverPort}/ping`); const APIHealth = await Http.get(`${usetls ? 'https' : 'http'}://localhost:${serverPort}/ping`);
const APIStatus = { const APIStatus = {
message: APIHealth.data, message: APIHealth.data,
responseTime: APIHealth.headers["x-response-time"], responseTime: APIHealth.headers["x-response-time"],
success: true success: true
}; };
logger.info("Received API status!", APIStatus);
return { return {
LNDStatus, LNDStatus,
APIStatus APIStatus
}; };
} catch (err) { } catch (err) {
console.error(err); logger.error(err);
const APIStatus = { const APIStatus = {
message: err.response.data, message: err.response.data,
responseTime: err.response.headers["x-response-time"], responseTime: err.response.headers["x-response-time"],
success: false success: false
}; };
logger.warn("Failed to retrieve API status", APIStatus);
return { return {
LNDStatus, LNDStatus,
APIStatus APIStatus
@ -307,10 +312,12 @@ module.exports = async (
*/ */
app.get("/healthz", async (req, res) => { app.get("/healthz", async (req, res) => {
const health = await checkHealth(); const health = await checkHealth();
logger.info("Healthz response:", health);
res.json(health); res.json(health);
}); });
app.get("/ping", (req, res) => { app.get("/ping", (req, res) => {
logger.info("Ping completed!");
res.json({ message: "OK" }); res.json({ message: "OK" });
}); });
@ -1205,7 +1212,7 @@ module.exports = async (
funding_txid_str: channelPoint, funding_txid_str: channelPoint,
output_index: outputIndex output_index: outputIndex
}, },
force: force force
}; };
logger.info("CloseChannelRequest", closeChannelRequest); logger.info("CloseChannelRequest", closeChannelRequest);
const closedChannel = lightning.closeChannel(closeChannelRequest); const closedChannel = lightning.closeChannel(closeChannelRequest);