SAP-BTP-Spielwiese/app1/node_modules/@sap/audit-logging/lib/v2/common.js
Markus Rettig 775ac7b58c completed step 3 from the tutorial
you must login with an BTP account in order to see the app
2024-02-08 16:13:36 +01:00

54 lines
1.2 KiB
JavaScript

'use strict';
var utils = require('../utils');
module.exports = {
log: log,
dataSubject: dataSubject,
logPrepare: logPrepare,
logSuccess: logSuccess,
logFailure: logFailure
};
function dataSubject(obj) {
utils.validate.dataSubject(obj, 'data-subject');
this._content['data_subject'] = obj;
return this;
}
function logPrepare(callback) {
if (this._content.hasOwnProperty('success')) {
var whichFunction = this._content.success ? logSuccess.name : logFailure.name;
throw new Error(whichFunction + ' already called on the current message');
}
return logWithStatus.call(this, undefined, callback);
}
function logSuccess(callback) {
return logWithStatus.call(this, true, callback);
}
function logFailure(callback) {
return logWithStatus.call(this, false, callback);
}
function logWithStatus(success, callback) {
if (callback) {
utils.validate.callback(callback);
}
this._update();
this._validateContent();
if (success !== undefined) {
this._content.success = success;
}
return this._transport.log(this, callback);
}
function log(callback) {
if (callback) {
utils.validate.callback(callback);
}
this._update();
this._validateContent();
return this._transport.log(this, callback);
}