import morgan from 'morgan';

function removeLastCharacter(text) {
    return text.slice(0, -1);
}

function removeEndingNewLineCharacter(message) {
    if (message.length > 0) {
        const lastCharacter = message[message.length - 1];

        if (lastCharacter === '\n') {
            return removeLastCharacter(message);
        }
    }

    return message;
}

function getInfoStream(logger) {
    return {
        write: (message) => {
            logger.info(removeEndingNewLineCharacter(message));
        }
    };
}

export default (logger) => {
    return morgan('combined', { stream: getInfoStream(logger) });
};

@@ -27,344 +27,8 @@
 ';%0A%0A
-function removeLastCharacter(text) %7B%0A    return text.slice(0, -1);%0A%7D%0A%0Afunction removeEndingNewLineCharacter(message) %7B%0A    if (message.length %3E 0) %7B%0A        const lastCharacter = message%5Bmessage.length - 1%5D;%0A%0A        if (lastCharacter === '%5Cn') %7B%0A            return removeLastCharacter(message);%0A        %7D%0A    %7D%0A%0A    return message;%0A%7D%0A%0A
 func
@@ -127,45 +127,16 @@
 nfo(
-removeEndingNewLineCharacter(
 message)
 );%0A 
@@ -131,17 +131,16 @@
 message)
-)
 ;%0A      

Remove obsolete functionality