@koreanpanda/inscriber
Version:
A Logger that can write logs, and print them, with full customization.
106 lines (105 loc) • 3.69 kB
JavaScript
;
/**========================================================================
* ? ABOUT
* @author : Cody Spratford
* @email : koreanpanda345@gmail.com
* @repo : https://github.com/koreanpanda345/Inscriber
* @createdOn : 11/21/2020
* @description : This is a builder for custom loggers.
* @since : 11/21/2020
*========================================================================**/
Object.defineProperty(exports, "__esModule", { value: true });
exports.CustomLogBuilder = void 0;
/**========================================================================
* Custom Log Builder
* @summary Builds the Custom Log Configuration for you.
* @example
*
* ```js
* const config = new CustomLogBuilder()
* .setName("Panda")
* .setAliases(["bamboo"])
* .setColor({text: "green"})
* .build();
* ```
*
*========================================================================**/
var CustomLogBuilder = /** @class */ (function () {
function CustomLogBuilder() {
this._config = {
name: "",
aliases: [],
path: "./Logs",
color: { text: "white", background: "black" },
pattern: "(<time>)\t[<type>]\t<message>",
};
}
/**==============================================
*
* @param name - The name you would like the log to be called.
*
*=============================================**/
CustomLogBuilder.prototype.setName = function (name) {
this._config.name = name;
this._config.path += "/" + name;
return this;
};
/**==============================================
*
* @param aliases - The aliases to be used for this log.
*
*=============================================**/
CustomLogBuilder.prototype.setAliases = function (aliases) {
if (aliases === void 0) {
aliases = [];
}
this._config.aliases = aliases;
return this;
};
/**==============================================
*
* @param path - The path that the logs should be written to.
*
*=============================================**/
CustomLogBuilder.prototype.setPath = function (path) {
if (path === void 0) {
path = "./Logs/" + this._config.name;
}
this._config.path = path;
return this;
};
/**==============================================
*
* @param pattern - The pattern that the log should use when writing logs.
*
*=============================================**/
CustomLogBuilder.prototype.setPattern = function (pattern) {
if (pattern === void 0) {
pattern = "(<time>)\t[<type>]\t<message>";
}
this._config.pattern = pattern;
return this;
};
/**==============================================
*
* @param color - what colors should the log use when priting the log out.
*
*=============================================**/
CustomLogBuilder.prototype.setColor = function (color) {
if (color === void 0) {
color = { text: "white", background: "black" };
}
this._config.color = color;
return this;
};
/**==============================================
*
* Builds the Custom Log Config.
*
*=============================================**/
CustomLogBuilder.prototype.build = function () {
return this._config;
};
return CustomLogBuilder;
})();
exports.CustomLogBuilder = CustomLogBuilder;