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:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
FWIW Here is module for some impure logging action: https://github.com/Undistraction/ramda-log
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.