import { logger } from '@island.is/logging' ; type ConsoleFn = typeof console . log ; const consoleLogWrapper = ( logFn ) => function ( message , extra ) { const hasMessage = typeof message === 'string' ; if ( arguments . length === 1 && hasMessage ) { return logFn ( message ) ; } else if ( arguments . length === 2 && hasMessage && typeof extra === 'object' ) { return logFn ( message , extra ) ; } const args = Array . from ( arguments ) ; const strings = args . filter ( ( arg ) => typeof arg === 'string' ) ; const objects = args . filter ( ( arg ) => typeof arg === 'object' ) ; message = strings . join ( ' ' ) ; extra = objects [ 0 ] ; if ( objects . length > 1 ) { extra = Object . assign ( { } , ... objects ) ; } logFn ( message , extra ) ; } ; export const monkeyPatchServerLogging = ( ) => { console . log = consoleLogWrapper ( logger . info . bind ( logger ) ) ; console . warn = consoleLogWrapper ( logger . warn . bind ( logger ) ) ; console . error = consoleLogWrapper ( logger . error . bind ( logger ) ) ; } ;