question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What about adding a simple log function that uses tap. Something simple that allows you to add a prefix and log the arg:

const log = prefix => tap(
  compose(
    console.log, 
    join(`: `),
    flip(append)([prefix]),
    JSON.stringify,
  )
)

const add3 = flip(add)(3);
const multi2 = multiply(2);
const sub1 = flip(subtract)(1);

const calc = compose(sub1, log(`Log`), multi2, add3); // Log: 16

There is a little discussion of something similar in Ramda’s issues here. I think it would be perfect for this library. We could of course allow the logging function to be configurable too.

const log = curry(
  (loggingFunction, prefix) => tap(
    compose(
      loggingFunction, 
      join(`: `),
      flip(append)([prefix]),
      JSON.stringify,
    )
  )
)

const logToConsole = log(console.log);

Could also allow the stringify function to be supplied.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Undistractioncommented, Feb 21, 2018

FWIW Here is module for some impure logging action: https://github.com/Undistraction/ramda-log

1reaction
Undistractioncommented, Jan 16, 2018

I can see how it isn’t a perfect fit for this library. Trying to cater to browser and server is potentially complex, and making it configurable removes its immediate utility. A separate lib makes sense.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Log Definition & Meaning - Merriam-Webster
verb ; 1 · to cut (trees) for lumber ; 2 · to make a note or record of : enter details of...
Read more >
Log - Wikipedia
Log ; Logging, cutting down trees for logs ; Firewood, logs used for fuel ; Lumber or timber, converted from wood logs.
Read more >
Log Definition & Meaning - Dictionary.com
a detailed record of a voyage of a ship or aircraft · a record of the hours flown by pilots and aircrews ·...
Read more >
LOG | definition in the Cambridge English Dictionary
log meaning: 1. a thick piece of tree trunk or branch, especially one cut for burning on a fire 2. a full…. Learn...
Read more >
log - Wiktionary
A unit of length equivalent to 16 feet, used for measuring timber, especially the trunk of a tree. Anything shaped like a log;...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found