Ce serveur Gitlab sera éteint le 30 juin 2020, pensez à migrer vos projets vers les serveurs gitlab-research.centralesupelec.fr et gitlab-student.centralesupelec.fr !

Commit a2e19385 authored by Doutre Julien's avatar Doutre Julien 🚀

Merge branch 'julien/init' into 'master'

Init package

See merge request !1
parents 1d65df18 da2ef3bf
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# next.js build output
.next
# infected-node-package
# Emoji-logger
An infected node package retrieving code to perform ZombieLoad attacks.
\ No newline at end of file
A fancy formatter for Winston!
## Usage
```javascript
// index.js
'use strict';
const { createLogger, transports } = require('winston');
const { fancy } = require("emoji-logger");
const logger = createLogger({
transports: [
new transports.Console(),
],
format: fancy,
});
logger.info("test");
// output:
// 🔥 info: test
```
You can also combine this formatter with others:
```javascript
// index.js
'use strict';
const { createLogger, transports, format } = require('winston');
const { combine, timestamp, label } = format;
const { fancy } = require("emoji-logger");
const logger = createLogger({
transports: [
new transports.Console(),
],
format: combine(timestamp(), label({ label: "test" }), fancy),
});
logger.info("message");
// output:
// 🔥 2019-11-20T13:03:21.716Z [test] info: message
```
'use strict';
// TODO: add sneaky code
const { format } = require('winston');
const isDefined = (a) => {
return typeof a !== 'undefined' && a !== null;
};
const chooseEmoji = (level) => {
let emoji;
switch (level) {
case 'debug':
emoji = '📝';
break;
case 'verbose':
emoji = '📌';
break;
case 'info':
emoji = '💡';
break;
case 'warn':
emoji = '⚠️';
break;
case 'error':
emoji = '🚨';
break;
default:
emoji = '🔥';
break;
}
return `${emoji} `;
};
exports.fancy = format.printf(
({ level, message, label, timestamp }) => {
let finalString = chooseEmoji(level);
if (isDefined(timestamp)) {
finalString += ` ${timestamp}`;
}
if (isDefined(label)) {
finalString += ` [${label}]`
}
finalString += ` ${level}: ${message}`;
return finalString;
}
);
{
"name": "emoji-logger",
"version": "1.0.0",
"description": "A fancy formatter for Winston!",
"main": "index.js",
"repository": {
"type": "git",
"url": "git@gitlab.centralesupelec.fr:scred-project/node-package.git"
},
"author": "John Doe",
"license": "MIT",
"dependencies": {
"winston": "^3.2.1"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment