diff options
author | eric <thul.eric@gmail.com> | 2016-02-27 20:16:49 -0500 |
---|---|---|
committer | eric <thul.eric@gmail.com> | 2016-02-27 20:16:49 -0500 |
commit | 0c1b65bb9b703543b5b00f8c571136d7ca1fe50d (patch) | |
tree | 7fbfb8f3bf11a3f3b5fbff95e58acdb8a6724627 /src/PursLoader | |
parent | 861ae3407e82b2ef0fd08f6d4ff7f2b0df0b3ed7 (diff) | |
parent | 3afbe2fddcc38ba6d79b01409f57158a217c00dd (diff) | |
download | purs-loader-0c1b65bb9b703543b5b00f8c571136d7ca1fe50d.tar.gz purs-loader-0c1b65bb9b703543b5b00f8c571136d7ca1fe50d.tar.zst purs-loader-0c1b65bb9b703543b5b00f8c571136d7ca1fe50d.zip |
Merge pull request #39 from ethul/topic/debug
Adding debug logging
Diffstat (limited to 'src/PursLoader')
-rw-r--r-- | src/PursLoader/Debug.js | 12 | ||||
-rw-r--r-- | src/PursLoader/Debug.purs | 9 | ||||
-rw-r--r-- | src/PursLoader/Loader.purs | 6 |
3 files changed, 27 insertions, 0 deletions
diff --git a/src/PursLoader/Debug.js b/src/PursLoader/Debug.js new file mode 100644 index 0000000..85eca10 --- /dev/null +++ b/src/PursLoader/Debug.js | |||
@@ -0,0 +1,12 @@ | |||
1 | 'use strict'; | ||
2 | |||
3 | // module PursLoader.Debug | ||
4 | |||
5 | var debug_ = require('debug')('purs-loader'); | ||
6 | |||
7 | function debug(message) { | ||
8 | return function(){ | ||
9 | debug_(message); | ||
10 | }; | ||
11 | } | ||
12 | exports.debug = debug; | ||
diff --git a/src/PursLoader/Debug.purs b/src/PursLoader/Debug.purs new file mode 100644 index 0000000..7a02f69 --- /dev/null +++ b/src/PursLoader/Debug.purs | |||
@@ -0,0 +1,9 @@ | |||
1 | module PursLoader.Debug (debug) where | ||
2 | |||
3 | import Prelude (Unit()) | ||
4 | |||
5 | import Control.Monad.Eff (Eff()) | ||
6 | |||
7 | import PursLoader.LoaderRef (Loader()) | ||
8 | |||
9 | foreign import debug :: forall eff. String -> Eff (loader :: Loader | eff) Unit | ||
diff --git a/src/PursLoader/Loader.purs b/src/PursLoader/Loader.purs index f78153f..5e00f7e 100644 --- a/src/PursLoader/Loader.purs +++ b/src/PursLoader/Loader.purs | |||
@@ -34,6 +34,7 @@ import PursLoader.LoaderRef | |||
34 | , resourcePath | 34 | , resourcePath |
35 | ) | 35 | ) |
36 | 36 | ||
37 | import PursLoader.Debug (debug) | ||
37 | import PursLoader.LoaderUtil (parseQuery) | 38 | import PursLoader.LoaderUtil (parseQuery) |
38 | import PursLoader.Options (Options(..)) | 39 | import PursLoader.Options (Options(..)) |
39 | import PursLoader.Path (dirname, relative) | 40 | import PursLoader.Path (dirname, relative) |
@@ -47,6 +48,8 @@ loader ref source = do | |||
47 | 48 | ||
48 | cacheable ref | 49 | cacheable ref |
49 | 50 | ||
51 | debug "Invoke PureScript plugin compilation" | ||
52 | |||
50 | pluginContext.compile (compile callback) | 53 | pluginContext.compile (compile callback) |
51 | where | 54 | where |
52 | pluginContext :: Plugin.Context (Effects eff) | 55 | pluginContext :: Plugin.Context (Effects eff) |
@@ -56,6 +59,8 @@ loader ref source = do | |||
56 | compile callback error' { srcMap, ffiMap, graph } = do | 59 | compile callback error' { srcMap, ffiMap, graph } = do |
57 | clearDependencies ref | 60 | clearDependencies ref |
58 | 61 | ||
62 | either (const $ pure unit) (\a -> debug ("Adding PureScript dependency " ++ a)) name | ||
63 | |||
59 | addDependency ref (resourcePath ref) | 64 | addDependency ref (resourcePath ref) |
60 | 65 | ||
61 | either (\err -> callback (Just err) "") id | 66 | either (\err -> callback (Just err) "") id |
@@ -63,6 +68,7 @@ loader ref source = do | |||
63 | where | 68 | where |
64 | handle :: String -> Array String -> String -> Eff (Effects eff) Unit | 69 | handle :: String -> Array String -> String -> Eff (Effects eff) Unit |
65 | handle name' deps res = do | 70 | handle name' deps res = do |
71 | debug ("Adding PureScript transitive dependencies for " ++ name') | ||
66 | addTransitive name' | 72 | addTransitive name' |
67 | foreachE deps addTransitive | 73 | foreachE deps addTransitive |
68 | callback (toMaybe error') res | 74 | callback (toMaybe error') res |