Security News
vlt Debuts New JavaScript Package Manager and Serverless Registry at NodeConf EU
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
A logging library for browsers and nodejs environment. It replaces console's logging functions (such as log, warn, error, info etc) with level-based logging.
It creates a wrapper over all the console's logging functions and provide decorators for extending the basic functionalities.
ES5+
)IE9+
: To support IE9 and IE10, Enabled loose mode in babelChrome 10+
Firefox 4+
Safari 6+
Opera 12+
NodeJS 0.5.1+
5KB
minified)info
console.log
if more specific ones aren't available eg: trace
is not available in IE9
Tech
ES6-7
SupportedESLint and Flow
Check enabledMocha, Sinon, Chai and Istanbul
NPM
npm install clogy
CDN
Development
:rawgit: //rawgit.com/pgmanutd/clogy/1.1.1/lib/clogy.js
or
unpkg: //unpkg.com/clogy@1.1.1/lib/clogy.js
Production
:rawgit: //cdn.rawgit.com/pgmanutd/clogy/1.1.1/lib/clogy.min.js
or
unpkg: //unpkg.com/clogy@1.1.1/lib/clogy.min.js
clogy supports AMD (e.g. RequireJS), CommonJS (e.g. NodeJS) and direct usage (e.g. loading globally (available as clogy
) with a <script>
tag):
const clogy = require('clogy');
clogy.info('Hello World');
define(['clogy'], (clogy) => {
clogy.info('Hello World again');
});
<script src="clogy.min.js"></script>
<script>
clogy.info('Hello script tag');
</script>
LEVELS
: Different log levels (along with values); use them to set the current log level. Order goes from top to bottom.
log
: 1trace
: 2debug
: 3info
: 4warn
: 5error
: 6none
: 7 (if current level is none, it won't log anything)If current log level is info
, then all the levels below info
are valid and rest are invalid. It means clogy.info()
, clogy.warn()
and clogy.error()
will work but clogy.log()
, clogy.trace()
and clogy.debug()
won't.
For example:
clogy.LEVELS.log; // 1
clogy.LEVELS.error; // 7
noConflict
: If you are using another JavaScript library that uses the clogy variable, you can run into conflicts with this library. In order to avoid these conflicts, you need to put clogy in no-conflict mode immediately after it is loaded onto the page and before you attempt to use clogy in your page. It works similar to jQuery's no-conflict mode.
For example:
const logger = clogy.noConflict();
logger.info('Still working');
setOptions
: (getOptions()
not required) Used for setting options (showDateTime
and prefix
)
For example:
clogy.setOptions({
showDateTime: true,
prefix: 'Github-'
});
where,
showDateTime
: It will prepend date and time along with :
For example:
clogy.setOptions({
showDateTime: true
});
clogy.info('Hello World'); // Wed Jul 27 2016 17:35:54.452: Hello World
prefix
: It will prepend a prefix. It will come after date and time (if enabled)
For example:
clogy.setOptions({
showDateTime: true,
prefix: 'Github-'
});
clogy.info('Hello World'); // Wed Jul 27 2016 17:35:54.452: Github- Hello World
getLevel
: Returns current log level; Default is info
For example:
clogy.getLevel(); // 4 for info and so on
setLevel
: Set current log level
For example:
clogy.setLevel(1); // log; number type argument
clogy.setLevel(clogy.LEVELS.log); // log; enum type argument
clogy.setLevel('log'); // log; string type argument
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)
For example:
clogy.disableAllLevels();
decorator
: Used to extend logging functionality. Can be used for:
For example:
clogy.log('Hello World'); // Hello World
clogy.decorator((originalLogger) => {
// Extending log method; you can extend any method
// (log/trace/debug/info/warn/error)
const originalLog = originalLogger.log;
// Don't use arrow functions here, because they will
// bind themselves to window or undefined in strict mode
originalLogger.log = function() {
// Please don't call clogy.log here, it will create a
// circular reference and throws
// "RangeError: Maximum call stack size exceeded" error
originalLog.apply(this, ['Github-', ...arguments]);
};
});
clogy.log('Hello World'); // Github- Hello World
(Default to log
, if not available eg: trace
is not available in IE9
)
log
: It will print log message
For example:
clogy.log('Hello World'); // Hello World
trace
: It will print trace message
For example:
clogy.trace('Hello World'); // Hello World
u @ clogy.min.js:1
(anonymous function) @ clogy.min.js:1
p.(anonymous function) @ clogy.min.js:1
(anonymous function) @ VM188:1
debug
: It will print debug message
For example:
clogy.debug('Hello World'); // Hello World
info
: It will print info message
For example:
clogy.info('Hello World'); // Hello World
warn
: It will print warn message
For example:
clogy.warn('Hello World'); // Hello World
error
: It will print error message
For example:
clogy.error('Hello World'); // Hello World
u @ clogy.min.js:1
(anonymous function) @ clogy.min.js:1
p.(anonymous function) @ clogy.min.js:1
(anonymous function) @ VM188:1
Anyone can help make this project better - check out the Contributing guide!
Copyright (c) 2016 pgmanutd
Licensed under the MIT license
Free Software, Hell Yeah!
1.1.1
FAQs
A logging library for browsers and nodejs environment
The npm package clogy receives a total of 220 weekly downloads. As such, clogy popularity was classified as not popular.
We found that clogy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
Security News
Research
The Socket Research Team uncovered a malicious Python package typosquatting the popular 'fabric' SSH library, silently exfiltrating AWS credentials from unsuspecting developers.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.