Skip to content

Commit

Permalink
Merge pull request #69 from KnpLabs/fix/log-timestamps
Browse files Browse the repository at this point in the history
Fix log timestamps
  • Loading branch information
alexpozzi authored Jun 23, 2021
2 parents db25fe7 + 87871a5 commit 093a01f
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions src/logger.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { F, always, bind, equals, findIndex, gte, ifElse, partial, pickAll } from 'ramda'
import { F, always, equals, findIndex, gte, ifElse, pickAll } from 'ramda'

/**
* @type Logger = {
Expand Down Expand Up @@ -36,40 +36,28 @@ const loggerHead = type => `[${(new Date()).toISOString()}] ${type.toUpperCase()
// error :: (String, Output) -> Function
const error = (level, output) => ifElse(
level => shouldPrintLog(level, LEVEL_ERROR),
() => partial(
bind(output.error, output),
[loggerHead(LEVEL_ERROR)],
),
() => (...args) => output.error(loggerHead(LEVEL_ERROR), ...args),
always(F),
)(level)

// warn :: (String, Output) -> Function
const warn = (level, output) => ifElse(
level => shouldPrintLog(level, LEVEL_WARN),
() => partial(
bind(output.warn, output),
[loggerHead(LEVEL_WARN)],
),
() => (...args) => output.warn(loggerHead(LEVEL_WARN), ...args),
always(F),
)(level)

// info :: (String, Output) -> Function
const info = (level, output) => ifElse(
level => shouldPrintLog(level, LEVEL_INFO),
() => partial(
bind(output.info, output),
[loggerHead(LEVEL_INFO)],
),
() => (...args) => output.info(loggerHead(LEVEL_INFO), ...args),
always(F),
)(level)

// debug :: (String, Output) -> Function
const debug = (level, output) => ifElse(
level => shouldPrintLog(level, LEVEL_DEBUG),
() => partial(
bind(output.log, output),
[loggerHead(LEVEL_DEBUG)],
),
() => (...args) => output.log(loggerHead(LEVEL_DEBUG), ...args),
always(F),
)(level)

Expand Down

0 comments on commit 093a01f

Please sign in to comment.