Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement