Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clogy

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clogy - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

7

CHANGELOG.md
# clogy changelog
## 1.2.0
- Added 2 new methods (getOptions and stringifyAllowedLoggers)
- Created separate file (common.js) for reusable methods
- Minor refactoring here and there
- Build related stuff (Added few options in webpack)
## 1.1.1

@@ -4,0 +11,0 @@

261

lib/clogy.js

@@ -1,2 +0,2 @@

/*! clogy - v1.1.1 * https://github.com/pgmanutd/clogy * (c) 2016 pgmanutd * licensed MIT */
/*! clogy - v1.2.0 * https://github.com/pgmanutd/clogy * (c) 2016 pgmanutd * licensed MIT */
(function webpackUniversalModuleDefinition(root, factory) {

@@ -58,3 +58,3 @@ if(typeof exports === 'object' && typeof module === 'object')

module.exports = __webpack_require__(4);
module.exports = __webpack_require__(5);

@@ -91,2 +91,87 @@

/* 2 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _loggingLevels = __webpack_require__(1);
var _loggingLevels2 = _interopRequireDefault(_loggingLevels);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// I prefer default export rather than named export
exports.default = {
isConsoleDefined: isConsoleDefined,
isLogLevelValid: isLogLevelValid,
isNoneLogLevel: isNoneLogLevel,
isLoggingAllowed: isLoggingAllowed,
getDateTime: getDateTime
};
////////////////////////
/**
* Check if console is available or not
* @return {Boolean} Returns true or false
*/
function isConsoleDefined() {
// No need of ===, typeof returns a string
return typeof console != 'undefined';
}
/**
* Check if current log level is valid, less than max
* and more than min log level
* @param {Number} logLevel: Current log level eg. 1, 2, 3, 4
* @return {Boolean} Returns true or false
*/
function isLogLevelValid(logLevel) {
return !!(logLevel && logLevel >= _loggingLevels2.default.range.min && logLevel <= _loggingLevels2.default.range.max);
}
/**
* Check if current log level is none thus logging is disabled
* @param {Number} logLevel: Current log level eg. 1, 2, 3, 4
* @return {Boolean} Returns true or false
*/
function isNoneLogLevel(logLevel) {
return logLevel === _loggingLevels2.default.types.none;
}
/**
* Check if level of passed log method is more than (or equal to) the
* current log level, thus allowing logging accordingly
* @param {Number} logLevel: Current log level eg. 1, 2, 3, 4
* @param {String} loggingType : logging method eg. log, info, error, warn
* @return {Boolean} Returns true or false
*/
function isLoggingAllowed(logLevel, loggingType) {
return _loggingLevels2.default.types[loggingType] >= logLevel;
}
/**
* Get current date and time
* @return {String} Returns date and time in string format
*/
function getDateTime() {
var d = new Date();
var date = d.toDateString();
// 0 means first matched string, which will be true always unless someone
// overrides the result
var time = d.toTimeString().match(/^([0-9]{2}:[0-9]{2}:[0-9]{2})/)[0];
// NOTE: hey..!! see, 3 is not a magic number, if you think it is, then
// it's just milliseconds in 3 digits (000-999)
var appendMilliseconds = ('00' + d.getMilliseconds()).slice(-3);
return date + ' ' + time + '.' + appendMilliseconds;
}
/***/ },
/* 3 */
/***/ function(module, exports) {

@@ -103,3 +188,3 @@

/***/ },
/* 3 */
/* 4 */
/***/ function(module, exports) {

@@ -113,3 +198,3 @@

/***/ },
/* 4 */
/* 5 */
/***/ function(module, exports, __webpack_require__) {

@@ -121,3 +206,3 @@

var _Clogy = __webpack_require__(5);
var _Clogy = __webpack_require__(6);

@@ -144,3 +229,3 @@ var _Clogy2 = _interopRequireDefault(_Clogy);

/***/ },
/* 5 */
/* 6 */
/***/ function(module, exports, __webpack_require__) {

@@ -152,7 +237,7 @@

var _singleton = __webpack_require__(8);
var _singleton = __webpack_require__(9);
var _singleton2 = _interopRequireDefault(_singleton);
var _Logger2 = __webpack_require__(6);
var _Logger2 = __webpack_require__(7);

@@ -231,3 +316,3 @@ var _Logger3 = _interopRequireDefault(_Logger2);

/***/ },
/* 6 */
/* 7 */
/***/ function(module, exports, __webpack_require__) {

@@ -243,3 +328,3 @@

var _loggingDefaultOptions = __webpack_require__(2);
var _loggingDefaultOptions = __webpack_require__(3);

@@ -252,8 +337,12 @@ var _loggingDefaultOptions2 = _interopRequireDefault(_loggingDefaultOptions);

var _loggingMethods = __webpack_require__(3);
var _loggingMethods = __webpack_require__(4);
var _loggingMethods2 = _interopRequireDefault(_loggingMethods);
var _logging = __webpack_require__(7);
var _common = __webpack_require__(2);
var _common2 = _interopRequireDefault(_common);
var _logging = __webpack_require__(8);
var _logging2 = _interopRequireDefault(_logging);

@@ -299,8 +388,16 @@

// Set default log level
this.setLevel(_loggingLevels2.default.types.info);
this.setLevel(this.LEVELS.info); // No need to use LOGGING_LEVELS.types.info again here
};
/**
* getOptions() not required
*
* Used for returning config options
* @return {Number | null} Returns config options
*/
Logger.prototype.getOptions = function getOptions() {
return this._options;
};
/**
* Used for setting options (showDateTime and prefix)

@@ -312,3 +409,3 @@ * @return {void | undefined} Returns nothing

Logger.prototype.setOptions = function setOptions(options) {
this._options = _extends({}, this._options, options);
this._options = _extends({}, this.getOptions(), options);
};

@@ -342,3 +439,3 @@

this._level = typeof level == 'string' ? // No need of ===, typeof returns a string
_loggingLevels2.default.types[level.toLowerCase()] : level;
this.LEVELS[level.toLowerCase()] : level;
};

@@ -370,7 +467,32 @@

/**
* Get stringifed allowed loggers (Order goes from top to bottom). Use utf-8 encoding for showing tick and cross marks, if not visible.
* @return {String} Returns stringifed allowed loggers
* @example:
* clogy.stringifyAllowedLoggers(); // When current log level is info
* => 1: log ✖
* 2: trace ✖
* 3: debug ✖
* 4: info ✔
* 5: warn ✔
* 6: error ✔
*/
Logger.prototype.stringifyAllowedLoggers = function stringifyAllowedLoggers() {
var _this = this;
var tickMark = '✔';
var crossMark = '✖';
return _loggingMethods2.default.map(function (loggingType, index) {
return index + 1 + ': ' + loggingType + ' ' + (_common2.default.isLoggingAllowed(_this.getLevel(), loggingType) ? tickMark : crossMark);
}).join('\n');
};
/**
* Enable all levels; equivalent to 'clogy.setLevel(clogy.LEVELS.log)''
* @return {void | undefined} Returns nothing
*/
Logger.prototype.enableAllLevels = function enableAllLevels() {
this.setLevel(_loggingLevels2.default.types.log);
this.setLevel(this.LEVELS.log);
};

@@ -385,3 +507,3 @@

Logger.prototype.disableAllLevels = function disableAllLevels() {
this.setLevel(_loggingLevels2.default.types.none);
this.setLevel(this.LEVELS.none);
};

@@ -423,3 +545,3 @@

loggingType: method,
options: this._options
options: this.getOptions()
};

@@ -441,3 +563,3 @@

/***/ },
/* 7 */
/* 8 */
/***/ function(module, exports, __webpack_require__) {

@@ -449,5 +571,5 @@

var _loggingLevels = __webpack_require__(1);
var _common = __webpack_require__(2);
var _loggingLevels2 = _interopRequireDefault(_loggingLevels);
var _common2 = _interopRequireDefault(_common);

@@ -468,62 +590,2 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
* Check if console is available or not
* @return {Boolean} Returns true or false
*/
function isConsoleDefined() {
// No need of ===, typeof returns a string
return typeof console != 'undefined';
}
/**
* Check if current log level is valid, less than max
* and more than min log level
* @param {Number} currentLogLevel: Current log level eg. 1, 2, 3, 4
* @return {Boolean} Returns true or false
*/
function isLogLevelValid(currentLogLevel) {
return !!(currentLogLevel && currentLogLevel >= _loggingLevels2.default.range.min && currentLogLevel <= _loggingLevels2.default.range.max);
}
/**
* Check if current log level is none thus logging is disabled
* @param {Number} currentLogLevel: Current log level eg. 1, 2, 3, 4
* @return {Boolean} Returns true or false
*/
function isNoneLogLevel(currentLogLevel) {
return currentLogLevel === _loggingLevels2.default.types.none;
}
/**
* Check if current log level is less than or equal to the level of current
* log method, thus allowing logging accordingly
* @param {Number} currentLogLevel: Current log level eg. 1, 2, 3, 4
* @param {String} loggingType : logging method eg. log, info, error, warn
* @return {Boolean} Returns true or false
*/
function isLoggingAllowed(currentLogLevel, loggingType) {
return _loggingLevels2.default.types[loggingType] >= currentLogLevel;
}
/**
* Get current date and time
* @return {String} Returns date and time in string format
*/
function getDateTime() {
var d = new Date();
var date = d.toDateString();
// 0 means first matched string, which will be true always unless someone
// overrides the result
var time = d.toTimeString().match(/^([0-9]{2}:[0-9]{2}:[0-9]{2})/)[0];
// NOTE: hey..!! see, 3 is not a magic number, if you think it is, then
// it's just milliseconds in 3 digits (000-999)
var appendMilliseconds = ('00' + d.getMilliseconds()).slice(-3);
return date + ' ' + time + '.' + appendMilliseconds;
}
/**
* Get console options and push them into an array (for logging)

@@ -533,2 +595,3 @@ * @param {Object} options: Console options like showDateTime, prefix

*/
function getConsoleOptions(options) {

@@ -540,3 +603,3 @@ var consoleOptions = [];

// Better readability than consoleOptions[consoleOptions.length] = value
consoleOptions.push(getDateTime() + ': ');
consoleOptions.push(_common2.default.getDateTime() + ': ');
}

@@ -586,3 +649,7 @@

* Functional style programming; No mutating params, no state known beforehand
* @param {Object} params: Object containing current log level ,
* @param {
currentLogLevel: number,
loggingType: string,
options: Object
} params: Object containing current log level ,
* log methods, default options like prefix

@@ -592,18 +659,20 @@ * @param {any} args : any value

*/
function logToConsole(params, args) {
if (!isConsoleDefined()) {
function logToConsole() {
var _ref = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var currentLogLevel = _ref.currentLogLevel;
var loggingType = _ref.loggingType;
var _ref$options = _ref.options;
var options = _ref$options === undefined ? {} : _ref$options;
var args = arguments[1];
if (!_common2.default.isConsoleDefined()) {
return;
}
var currentLogLevel = params.currentLogLevel;
var loggingType = params.loggingType;
var _params$options = params.options;
var options = _params$options === undefined ? {} : _params$options;
if (!isLogLevelValid(currentLogLevel)) {
if (!_common2.default.isLogLevelValid(currentLogLevel)) {
throw new RangeError('Invalid LogLevel set, Please set a valid LogLevel');
}
if (isNoneLogLevel(currentLogLevel) || !isLoggingAllowed(currentLogLevel, loggingType)) {
if (_common2.default.isNoneLogLevel(currentLogLevel) || !_common2.default.isLoggingAllowed(currentLogLevel, loggingType)) {
return;

@@ -617,3 +686,3 @@ }

/***/ },
/* 8 */
/* 9 */
/***/ function(module, exports) {

@@ -620,0 +689,0 @@

@@ -1,3 +0,3 @@

/*! clogy - v1.1.1 * https://github.com/pgmanutd/clogy * (c) 2016 pgmanutd * licensed MIT */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.clogy=t():e.clogy=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(4)},function(e,t){"use strict";t.__esModule=!0,t["default"]={get types(){return{log:1,trace:2,debug:3,info:4,warn:5,error:6,none:7}},get range(){return{min:this.types.log,max:this.types.none}}}},function(e,t){"use strict";t.__esModule=!0,t["default"]={showDateTime:!1,prefix:""}},function(e,t){"use strict";t.__esModule=!0,t["default"]=["log","trace","debug","info","warn","error"]},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var r=n(5),u=o(r),i=new u["default"];t["default"]=i,e.exports=i},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var l=n(8),f=o(l),s=n(6),c=o(s),a=function(e){function t(){return r(this,t),u(this,e.apply(this,arguments))}return i(t,e),t.prototype.noConflict=function(){return"undefined"!=typeof window&&window.clogy&&delete window.clogy,this},t.prototype.decorator=function(e){if("function"!=typeof e)throw new TypeError("Decorator should be a function");e(f["default"].getInstance(this))},t}(c["default"]);t["default"]=a},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},i=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),l=n(2),f=o(l),s=n(1),c=o(s),a=n(3),p=o(a),d=n(7),y=o(d),g=function(){function e(){r(this,e),this._options={showDateTime:null,prefix:null},this._level=null,this._setDefaults()}return e.prototype._setDefaults=function(){this.setOptions(f["default"]),this.setLevel(c["default"].types.info)},e.prototype.setOptions=function(e){this._options=u({},this._options,e)},e.prototype.getLevel=function(){return this._level},e.prototype.setLevel=function(e){this._level="string"==typeof e?c["default"].types[e.toLowerCase()]:e},e.prototype.enableAllLevels=function(){this.setLevel(c["default"].types.log)},e.prototype.disableAllLevels=function(){this.setLevel(c["default"].types.none)},i(e,[{key:"LEVELS",get:function(){return c["default"].types}}]),e}(),h=g.prototype;p["default"].forEach(function(e){h[e]=function(){for(var t={currentLogLevel:this.getLevel(),loggingType:e,options:this._options},n=arguments.length,o=Array(n),r=0;r<n;r++)o[r]=arguments[r];y["default"].logToConsole(t,o)}}),t["default"]=g},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function r(){return"undefined"!=typeof console}function u(e){return!!(e&&e>=d["default"].range.min&&e<=d["default"].range.max)}function i(e){return e===d["default"].types.none}function l(e,t){return d["default"].types[t]>=e}function f(){var e=new Date,t=e.toDateString(),n=e.toTimeString().match(/^([0-9]{2}:[0-9]{2}:[0-9]{2})/)[0],o=("00"+e.getMilliseconds()).slice(-3);return t+" "+n+"."+o}function s(e){var t=[];return e.showDateTime&&t.push(f()+": "),e.prefix&&t.push(e.prefix),t}function c(e,t){var n=console[e]||console[y];n&&Function.prototype.bind.call(n,console).apply(console,t)}function a(e,t){if(r()){var n=e.currentLogLevel,o=e.loggingType,f=e.options,a=void 0===f?{}:f;if(!u(n))throw new RangeError("Invalid LogLevel set, Please set a valid LogLevel");!i(n)&&l(n,o)&&c(o,[].concat(s(a),t))}}t.__esModule=!0;var p=n(1),d=o(p),y="log";t["default"]={logToConsole:a}},function(e,t){"use strict";function n(e){var t=Object.getPrototypeOf;return t(t(e))}function o(e){return r||(r=n(e)),r}t.__esModule=!0;var r=void 0;t["default"]={getInstance:o}}])});
/*! clogy - v1.2.0 * https://github.com/pgmanutd/clogy * (c) 2016 pgmanutd * licensed MIT */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.clogy=t():e.clogy=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(5)},function(e,t){"use strict";t.__esModule=!0,t["default"]={get types(){return{log:1,trace:2,debug:3,info:4,warn:5,error:6,none:7}},get range(){return{min:this.types.log,max:this.types.none}}}},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function r(){return"undefined"!=typeof console}function i(e){return!!(e&&e>=c["default"].range.min&&e<=c["default"].range.max)}function u(e){return e===c["default"].types.none}function l(e,t){return c["default"].types[t]>=e}function s(){var e=new Date,t=e.toDateString(),n=e.toTimeString().match(/^([0-9]{2}:[0-9]{2}:[0-9]{2})/)[0],o=("00"+e.getMilliseconds()).slice(-3);return t+" "+n+"."+o}t.__esModule=!0;var f=n(1),c=o(f);t["default"]={isConsoleDefined:r,isLogLevelValid:i,isNoneLogLevel:u,isLoggingAllowed:l,getDateTime:s}},function(e,t){"use strict";t.__esModule=!0,t["default"]={showDateTime:!1,prefix:""}},function(e,t){"use strict";t.__esModule=!0,t["default"]=["log","trace","debug","info","warn","error"]},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var r=n(6),i=o(r),u=new i["default"];t["default"]=u,e.exports=u},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var l=n(9),s=o(l),f=n(7),c=o(f),a=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return u(t,e),t.prototype.noConflict=function(){return"undefined"!=typeof window&&window.clogy&&delete window.clogy,this},t.prototype.decorator=function(e){if("function"!=typeof e)throw new TypeError("Decorator should be a function");e(s["default"].getInstance(this))},t}(c["default"]);t["default"]=a},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},u=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),l=n(3),s=o(l),f=n(1),c=o(f),a=n(4),p=o(a),d=n(2),g=o(d),y=n(8),h=o(y),v=function(){function e(){r(this,e),this._options={showDateTime:null,prefix:null},this._level=null,this._setDefaults()}return e.prototype._setDefaults=function(){this.setOptions(s["default"]),this.setLevel(this.LEVELS.info)},e.prototype.getOptions=function(){return this._options},e.prototype.setOptions=function(e){this._options=i({},this.getOptions(),e)},e.prototype.getLevel=function(){return this._level},e.prototype.setLevel=function(e){this._level="string"==typeof e?this.LEVELS[e.toLowerCase()]:e},e.prototype.stringifyAllowedLoggers=function(){var e=this,t="✔",n="✖";return p["default"].map(function(o,r){return r+1+": "+o+" "+(g["default"].isLoggingAllowed(e.getLevel(),o)?t:n)}).join("\n")},e.prototype.enableAllLevels=function(){this.setLevel(this.LEVELS.log)},e.prototype.disableAllLevels=function(){this.setLevel(this.LEVELS.none)},u(e,[{key:"LEVELS",get:function(){return c["default"].types}}]),e}(),L=v.prototype;p["default"].forEach(function(e){L[e]=function(){for(var t={currentLogLevel:this.getLevel(),loggingType:e,options:this.getOptions()},n=arguments.length,o=Array(n),r=0;r<n;r++)o[r]=arguments[r];h["default"].logToConsole(t,o)}}),t["default"]=v},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function r(e){var t=[];return e.showDateTime&&t.push(s["default"].getDateTime()+": "),e.prefix&&t.push(e.prefix),t}function i(e,t){var n=console[e]||console[f];n&&Function.prototype.bind.call(n,console).apply(console,t)}function u(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],t=e.currentLogLevel,n=e.loggingType,o=e.options,u=void 0===o?{}:o,l=arguments[1];if(s["default"].isConsoleDefined()){if(!s["default"].isLogLevelValid(t))throw new RangeError("Invalid LogLevel set, Please set a valid LogLevel");!s["default"].isNoneLogLevel(t)&&s["default"].isLoggingAllowed(t,n)&&i(n,[].concat(r(u),l))}}t.__esModule=!0;var l=n(2),s=o(l),f="log";t["default"]={logToConsole:u}},function(e,t){"use strict";function n(e){var t=Object.getPrototypeOf;return t(t(e))}function o(e){return r||(r=n(e)),r}t.__esModule=!0;var r=void 0;t["default"]={getInstance:o}}])});
//# sourceMappingURL=clogy.min.js.map
{
"name": "clogy",
"version": "1.1.1",
"version": "1.2.0",
"description": "A logging library for browsers and nodejs environment",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/pgmanutd/clogy",

@@ -17,3 +17,3 @@ # clogy [![npm](https://img.shields.io/npm/v/clogy.svg)](https://www.npmjs.com/package/clogy) [![Build Status](https://travis-ci.org/pgmanutd/clogy.svg?branch=master)](https://travis-ci.org/pgmanutd/clogy) [![Coverage Status](https://coveralls.io/repos/github/pgmanutd/clogy/badge.svg?branch=master)](https://coveralls.io/github/pgmanutd/clogy?branch=master)

----
* Very lightweight (```5KB``` minified)
* Very lightweight (```~5.5KB``` minified)
* No dependencies

@@ -47,15 +47,15 @@ * Log at a given level (log/trace/debug/info/warn/error) to the console

**rawgit**: ```//rawgit.com/pgmanutd/clogy/1.1.1/lib/clogy.js```
**rawgit**: ```//rawgit.com/pgmanutd/clogy/1.2.0/lib/clogy.js```
or
**unpkg**: ```//unpkg.com/clogy@1.1.1/lib/clogy.js```
**unpkg**: ```//unpkg.com/clogy@1.2.0/lib/clogy.js```
* ```Production```:
**rawgit**: ```//cdn.rawgit.com/pgmanutd/clogy/1.1.1/lib/clogy.min.js```
**rawgit**: ```//cdn.rawgit.com/pgmanutd/clogy/1.2.0/lib/clogy.min.js```
or
**unpkg**: ```//unpkg.com/clogy@1.1.1/lib/clogy.min.js```
**unpkg**: ```//unpkg.com/clogy@1.2.0/lib/clogy.min.js```

@@ -120,10 +120,10 @@

* ```setOptions```: (```getOptions()``` not required) Used for setting options (```showDateTime``` and ```prefix```)
* ```getOptions```: Returns options (```showDateTime``` and ```prefix```). Probably this might not required for normal application; it's provided to let user know the current options (may be when user is extending the logging functionality using decorators).
For example:
```
clogy.setOptions({
showDateTime: true,
prefix: 'Github-'
});
clogy.getOptions(); //{
showDateTime: true,
prefix: 'Github-'
}
```

@@ -133,3 +133,3 @@

* ```showDateTime```: It will prepend date and time along with ```:```
* ```showDateTime```: It will prepend date and time along with ```:``` and a space. Space is required for ```IE``` where multiple statements are sticked together.
* **Type**: Boolean

@@ -145,3 +145,3 @@ * **Default**: false

```
* ```prefix```: It will prepend a prefix. It will come after date and time (if enabled)
* ```prefix```: It will prepend a prefix. It will come after date and time (if enabled).
* **Type**: String

@@ -159,10 +159,20 @@ * **Default**: '' (Emtpy)

* ```getLevel```: Returns current log level; Default is ```info```
* ```setOptions```: Used for setting options (```showDateTime``` and ```prefix```).
For example:
```
clogy.setOptions({
showDateTime: true,
prefix: 'Github-'
});
```
* ```getLevel```: Returns current log level; Default is ```info```. Probably this might not required for normal application; it's provided to let user know the current log level (may be when user is extending the logging functionality using decorators or skipping logging for any level (```clogy.getLevel() === clogy.LEVELS.info ? 'skip : 'proceed'```)).
For example:
```
clogy.getLevel(); // 4 for info and so on
```
* ```setLevel```: Set current log level
* ```setLevel```: Set current log level.

@@ -176,10 +186,23 @@ For example:

* ```enableAllLevels```: Enable all levels; equivalent to ```clogy.setLevel(clogy.LEVELS.log)```
* ```stringifyAllowedLoggers```: Get stringifed allowed loggers (Order goes from top to bottom). Use utf-8 encoding for showing tick and cross marks, if not visible.
For example:
```
clogy.stringifyAllowedLoggers(); // When current log level is info
1: log ✖
2: trace ✖
3: debug ✖
4: info ✔
5: warn ✔
6: error ✔
```
* ```enableAllLevels```: Enable all levels; equivalent to ```clogy.setLevel(clogy.LEVELS.log)```.
For example:
```
clogy.enableAllLevels();
```
* ```disableAllLevels```: Disable all levels; equivalent to ```clogy.setLevel(clogy.LEVELS.none)```
* ```disableAllLevels```: Disable all levels; equivalent to ```clogy.setLevel(clogy.LEVELS.none)```.

@@ -209,2 +232,3 @@ For example:

originalLogger.log = function() {
// See, we are just mutating the parameter's property (which is fine in this case) for extending the functionality

@@ -224,3 +248,3 @@ // Please don't call clogy.log here, it will create a

* ```log```: It will print log message
* ```log```: It will print log message.

@@ -232,3 +256,3 @@ For example:

* ```trace```: It will print trace message
* ```trace```: It will print trace message.

@@ -243,3 +267,3 @@ For example:

```
* ```debug```: It will print debug message
* ```debug```: It will print debug message.

@@ -251,3 +275,3 @@ For example:

* ```info```: It will print info message
* ```info```: It will print info message.

@@ -259,3 +283,3 @@ For example:

* ```warn```: It will print warn message
* ```warn```: It will print warn message.

@@ -267,3 +291,3 @@ For example:

* ```error```: It will print error message
* ```error```: It will print error message.

@@ -270,0 +294,0 @@ For example:

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc