Last active
May 27, 2016 02:23
-
-
Save princejwesley/acca778c9221e2bdc5d2121d4a489f9b to your computer and use it in GitHub Desktop.
[elm] Toggle on/off Debug.log
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Toggle Debug.log | |
-- For non production use only | |
import Debug exposing(log) | |
-- (1) with |> | |
1 + 1 |> log "Addition" -- prints "Addition: 2" and returns 2 | |
-- turn off logging | |
1 + 1 -- |> log "Addition" | |
-- (2) with flip | |
flog = flip log | |
(1 + 1) `flog` "Addition" -- prints "Addition: 2" and returns 2 | |
-- turn off logging | |
(1 + 1) -- `flog` "Addition" | |
-- (3) with xlog | |
xlog _ l = l | |
1 + (log "num" 1) -- prints "num: 1" and returns 2 | |
-- turn off logging | |
1 + (xlog "num" 1) -- prints nothing and returns 2 | |
-- (4) without exposing log | |
-- turn off/on all logs in a file | |
log = Debug.log | |
-- log _ l = l | |
1 + (log "num" 1) -- prints "num: 1" and returns 2 | |
-- turn off logging | |
-- log = Debug.log | |
log _ l = l | |
1 + (log "num" 1) -- prints nothing and returns 2 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment