Every new project starts with some shape or form of

console.log('Hello World')

From there we escalate. Log this and that. Error here error there. After a while our prototypes are finished and we need to connect our logs to some service. What service to choose one maybe doesn't know while starting to code or just doesn't care to think of. That's why I want to share my basic logging (Typescript-)template, which i just drop into a project at the beginning before typing my first console.log.

The usage of this is rather easy:

import getLogger from './logger'
const logger = getLogger('server')
//...
//..

logger.log('Hi There')

This small pattern allows for easy customization in basically every usecase. The factory method enables enviroment based checking e.g. for emitting different implementations of Logger. In frontend development you also could remove all the logs in production while keeping them in the console while doing the actual development.