Advertisement
Guest User

Untitled

a guest
May 26th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. -- Toggle Debug.log
  2. -- For non production use only
  3.  
  4. import Debug exposing(log)
  5.  
  6. -- (1) with |>
  7.  
  8. 1 + 1 |> log "Addition" -- prints "Addition: 2" and returns 2
  9. -- turn off logging
  10. 1 + 1 -- |> log "Addition"
  11.  
  12. -- (2) with flip
  13.  
  14. flog = flip log
  15.  
  16. (1 + 1) `flog` "Addition" -- prints "Addition: 2" and returns 2
  17. -- turn off logging
  18. (1 + 1) -- `flog` "Addition"
  19.  
  20. -- (3) with xlog
  21.  
  22. xlog _ l = l
  23.  
  24. 1 + (log "num" 1) -- prints "num: 1" and returns 2
  25. -- turn off logging
  26. 1 + (xlog "num" 1) -- prints nothing and returns 2
  27.  
  28.  
  29. -- (4) without exposing log
  30. -- turn off/on all logs in a file
  31.  
  32. log = Debug.log
  33. -- log _ l = l
  34.  
  35. 1 + (log "num" 1) -- prints "num: 1" and returns 2
  36.  
  37. -- turn off logging
  38.  
  39. -- log = Debug.log
  40. log _ l = l
  41.  
  42. 1 + (log "num" 1) -- prints nothing and returns 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement