Skip to content

Instantly share code, notes, and snippets.

0485537b4407d79d0994a030a206b52de9a29573b0425a674c5488cb445c7a99772da978f4d8925a61fb48958460d484b165b0f38d46487b1495a064731502d7e9;BeauAgst
@tigranpetrossian
tigranpetrossian / logger.js
Last active January 10, 2021 00:07
Winston logger with added ability of namespacing and controlling severity levels with environment variables
import winston, { format, createLogger, transports } from 'winston';
import DailyRotateFile from 'winston-daily-rotate-file';
const { combine, timestamp, label, printf } = format;
const formatConsoleMessage = printf((info) => {
const { timestamp, label, level, message } = info;
return `${timestamp} ${(level + ':').padEnd(16)} [${label}] ${message}`;
});
const logger = createLogger({
@tigranpetrossian
tigranpetrossian / fonts.js
Created October 16, 2018 20:06
Storing base64 encoded fonts in localStorage. Prevents FOIT on initial visit, and FOUT on subsequent visits.
// Load fonts
//
// The technique is a combination of using fontfaceobserver and storing data-uri
// encoded fonts in the localstorage for perfect font loading experience.
//
// FontFaceObserver eliminates any visible flicker (FOIT) during the initial load,
// by simply swtiching from fallback to primary typeface when fonts are loaded.
// Permanently caching fonts as a CSS file in localstorage completely eliminates FOUT on subsequent visits.
//
// https://www.smashingmagazine.com/2014/09/improving-smashing-magazine-performance-case-study/#webfonts