mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-23 07:42:10 +00:00
Merge branch 'master' into admin-dashboard
This commit is contained in:
commit
41c7f3c4fb
@ -28,27 +28,35 @@ export default class Response {
|
||||
|
||||
const requestEndedAt: Date = new Date();
|
||||
const method: string = oneUptimeRequest.method;
|
||||
const url: URL = URL.fromString(oneUptimeRequest.url);
|
||||
const path: string = oneUptimeRequest.originalUrl.toString();
|
||||
|
||||
const header_info: string = `Response ID: ${
|
||||
oneUptimeRequest.id
|
||||
} -- POD NAME: ${
|
||||
process.env['POD_NAME'] || 'NONE'
|
||||
} -- METHOD: ${method} -- URL: ${url.toString()} -- DURATION: ${(
|
||||
const logLine: JSONObject = {
|
||||
'Request ID': `${oneUptimeRequest.id}`,
|
||||
|
||||
'Pod Name': `${process.env['POD_NAME'] || 'NONE'}`,
|
||||
|
||||
'HTTP Method': `${method}`,
|
||||
|
||||
'Path': `${path.toString()}`,
|
||||
|
||||
'Request Duration': `${(
|
||||
requestEndedAt.getTime() -
|
||||
(oneUptimeRequest.requestStartedAt as Date).getTime()
|
||||
).toString()}ms -- STATUS: ${oneUptimeResponse.statusCode}`;
|
||||
).toString()}ms`,
|
||||
|
||||
const body_info: string = `Response ID: ${
|
||||
oneUptimeRequest.id
|
||||
} -- RESPONSE BODY: ${
|
||||
'Response Status': `${oneUptimeResponse.statusCode}`,
|
||||
|
||||
'Host': `${oneUptimeRequest.hostname}`,
|
||||
|
||||
'Response body': `${
|
||||
responsebody ? JSON.stringify(responsebody, null, 2) : 'EMPTY'
|
||||
}`;
|
||||
}`,
|
||||
};
|
||||
|
||||
if (oneUptimeResponse.statusCode > 299) {
|
||||
logger.error(header_info + '\n ' + body_info);
|
||||
logger.error(logLine);
|
||||
} else {
|
||||
logger.info(header_info + '\n ' + body_info);
|
||||
logger.info(logLine);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,6 +74,7 @@ export default class CallService {
|
||||
if (!project) {
|
||||
callLog.status = CallStatus.Error;
|
||||
callLog.statusMessage = `Project ${options.projectId.toString()} not found.`;
|
||||
logger.error(callLog.statusMessage);
|
||||
await CallLogService.create({
|
||||
data: callLog,
|
||||
props: {
|
||||
@ -86,7 +87,7 @@ export default class CallService {
|
||||
if (!project.enableCallNotifications) {
|
||||
callLog.status = CallStatus.Error;
|
||||
callLog.statusMessage = `Call notifications are not enabled for this project. Please enable Call notifications in Project Settings.`;
|
||||
|
||||
logger.error(callLog.statusMessage);
|
||||
await CallLogService.create({
|
||||
data: callLog,
|
||||
props: {
|
||||
@ -132,6 +133,7 @@ export default class CallService {
|
||||
if (!project.smsOrCallCurrentBalanceInUSDCents) {
|
||||
callLog.status = CallStatus.LowBalance;
|
||||
callLog.statusMessage = `Project ${options.projectId.toString()} does not have enough Call balance.`;
|
||||
logger.error(callLog.statusMessage);
|
||||
await CallLogService.create({
|
||||
data: callLog,
|
||||
props: {
|
||||
@ -175,6 +177,7 @@ export default class CallService {
|
||||
} USD. Required balance is ${
|
||||
CallDefaultCostInCentsPerMinute / 100
|
||||
} USD to make this call.`;
|
||||
logger.error(callLog.statusMessage);
|
||||
await CallLogService.create({
|
||||
data: callLog,
|
||||
props: {
|
||||
@ -218,7 +221,8 @@ export default class CallService {
|
||||
|
||||
callLog.status = CallStatus.Success;
|
||||
callLog.statusMessage = 'Call ID: ' + twillioCall.sid;
|
||||
|
||||
logger.info('Call Request sent successfully.');
|
||||
logger.info(callLog.statusMessage);
|
||||
if (IsBillingEnabled && project) {
|
||||
callLog.callCostInUSDCents = CallDefaultCostInCentsPerMinute;
|
||||
|
||||
@ -251,6 +255,9 @@ export default class CallService {
|
||||
callLog.status = CallStatus.Error;
|
||||
callLog.statusMessage =
|
||||
e && e.message ? e.message.toString() : e.toString();
|
||||
|
||||
logger.error('Call Request failed.');
|
||||
logger.error(callLog.statusMessage);
|
||||
}
|
||||
|
||||
if (options.projectId) {
|
||||
|
@ -71,6 +71,7 @@ export default class SmsService {
|
||||
if (!project) {
|
||||
smsLog.status = SmsStatus.Error;
|
||||
smsLog.statusMessage = `Project ${options.projectId.toString()} not found.`;
|
||||
logger.error(smsLog.statusMessage);
|
||||
await SmsLogService.create({
|
||||
data: smsLog,
|
||||
props: {
|
||||
@ -83,7 +84,7 @@ export default class SmsService {
|
||||
if (!project.enableSmsNotifications) {
|
||||
smsLog.status = SmsStatus.Error;
|
||||
smsLog.statusMessage = `SMS notifications are not enabled for this project. Please enable SMS notifications in Project Settings.`;
|
||||
|
||||
logger.error(smsLog.statusMessage);
|
||||
await SmsLogService.create({
|
||||
data: smsLog,
|
||||
props: {
|
||||
@ -128,6 +129,7 @@ export default class SmsService {
|
||||
if (!project.smsOrCallCurrentBalanceInUSDCents) {
|
||||
smsLog.status = SmsStatus.LowBalance;
|
||||
smsLog.statusMessage = `Project ${options.projectId.toString()} does not have enough SMS balance.`;
|
||||
logger.error(smsLog.statusMessage);
|
||||
await SmsLogService.create({
|
||||
data: smsLog,
|
||||
props: {
|
||||
@ -171,6 +173,7 @@ export default class SmsService {
|
||||
} USD. Required balance is ${
|
||||
SMSDefaultCostInCents / 100
|
||||
} USD to send this SMS.`;
|
||||
logger.error(smsLog.statusMessage);
|
||||
await SmsLogService.create({
|
||||
data: smsLog,
|
||||
props: {
|
||||
@ -216,6 +219,9 @@ export default class SmsService {
|
||||
smsLog.status = SmsStatus.Success;
|
||||
smsLog.statusMessage = 'Message ID: ' + twillioMessage.sid;
|
||||
|
||||
logger.info('SMS message sent successfully.');
|
||||
logger.info(smsLog.statusMessage);
|
||||
|
||||
if (IsBillingEnabled && project) {
|
||||
smsLog.smsCostInUSDCents = SMSDefaultCostInCents;
|
||||
|
||||
@ -241,6 +247,9 @@ export default class SmsService {
|
||||
smsLog.status = SmsStatus.Error;
|
||||
smsLog.statusMessage =
|
||||
e && e.message ? e.message.toString() : e.toString();
|
||||
|
||||
logger.error('SMS message failed to send.');
|
||||
logger.error(smsLog.statusMessage);
|
||||
}
|
||||
|
||||
if (options.projectId) {
|
||||
|
Loading…
Reference in New Issue
Block a user