sp-js-provisioning
Version:
SharePoint provisioning with pure JavaScript
102 lines • 3.17 kB
JavaScript
import { Logger } from '@pnp/logging';
/**
* Describes the Object Handler Base
*/
var HandlerBase = /** @class */ (function () {
/**
* Creates a new instance of the ObjectHandlerBase class
*
* @param name - Name
* @param config - Config
*/
function HandlerBase(name, config) {
if (config === void 0) { config = {}; }
this.config = {};
this.name = name;
this.config = config;
}
/**
* Provisioning objects
*/
HandlerBase.prototype.ProvisionObjects = function (web, templatePart,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
_context) {
Logger.log({
data: templatePart,
level: 2 /* Warning */,
message: "Handler " + this.name + " for web [" + web.toUrl() + "] does not override ProvisionObjects."
});
return Promise.resolve();
};
/**
* Writes to Logger when scope has started
*/
HandlerBase.prototype.scope_started = function () {
this.log_info('ProvisionObjects', 'Code execution scope started');
};
/**
* Writes to Logger when scope has stopped
*
* @param error - Error
*/
HandlerBase.prototype.scope_ended = function (error) {
if (error)
this.log_error('ProvisionObjects', "Code execution scope ended with error: " + error.message);
else
this.log_info('ProvisionObjects', 'Code execution scope ended');
};
/**
* Writes to Logger
*
* @param scope - Scope
* @param message - Message
* @param data - Data
*/
HandlerBase.prototype.log_info = function (scope, message, data) {
var prefix = this.config.logging && this.config.logging.prefix
? this.config.logging.prefix + " "
: '';
Logger.log({
message: prefix + "(" + this.name + "): (" + scope + "): " + message,
data: data,
level: 1 /* Info */
});
};
/**
* Writes a warning to the logger
*
* @param scope - Scope
* @param message - Message
* @param data - Data
*/
HandlerBase.prototype.log_warn = function (scope, message, data) {
var prefix = this.config.logging && this.config.logging.prefix
? this.config.logging.prefix + " "
: '';
Logger.log({
message: prefix + "(" + this.name + "): (" + scope + "): " + message,
data: data,
level: 2 /* Warning */
});
};
/**
* Writes an error to the logger
*
* @param scope - Scope
* @param message - Message
* @param data - Data
*/
HandlerBase.prototype.log_error = function (scope, message, data) {
var prefix = this.config.logging && this.config.logging.prefix
? this.config.logging.prefix + " "
: '';
Logger.log({
message: prefix + "(" + this.name + "): (" + scope + "): " + message,
data: data,
level: 3 /* Error */
});
};
return HandlerBase;
}());
export { HandlerBase };
//# sourceMappingURL=handlerbase.js.map