Skip to content

Instantly share code, notes, and snippets.

View emg110's full-sized avatar
๐ŸŒ
VERIFIABLE AGENCY

MG emg110

๐ŸŒ
VERIFIABLE AGENCY
View GitHub Profile
const fs = require('fs');
const logger = require('./logger');//JUST PICKUP A LOGGER LIKE THIS LOGGER HERE: https://gist.github.com/emg110/1ab0584ff59b6f216304ec68b0977f7c
const { Client } = require('@elastic/elasticsearch');
const client = new Client({ node: 'http://YOUR_ES_SERVER:ES_HTTP/S_PORT' });
const inStream = fs.createReadStream('././data/YOUR_NEDB_FILE.db');
var lineReader = require('readline').createInterface({
input: inStream
});
async function writeToES(doc){
await client.index({
@emg110
emg110 / winston_3_customization_by_chalk.js
Last active April 26, 2022 08:41
Winston 3 customization by chalk
const { createLogger, format, transports } = require('winston');
const chalk = require('chalk');
const { combine, timestamp, label, printf, simple, splat } = format;
const consoleFormat = printf(({ level, message, label, timestamp }) => {
var levelUpper = level.toUpperCase();
switch (levelUpper) {
case "INFO":
message = chalk.green(message);
level = chalk.black.bgGreenBright.bold(level);
break;