From 3afbe2fddcc38ba6d79b01409f57158a217c00dd Mon Sep 17 00:00:00 2001 From: eric thul Date: Sat, 27 Feb 2016 20:15:10 -0500 Subject: Adding debug logging --- docs/PursLoader/Debug.md | 9 +++++++++ package.json | 1 + src/PursLoader/Debug.js | 12 ++++++++++++ src/PursLoader/Debug.purs | 9 +++++++++ src/PursLoader/Loader.purs | 6 ++++++ 5 files changed, 37 insertions(+) create mode 100644 docs/PursLoader/Debug.md create mode 100644 src/PursLoader/Debug.js create mode 100644 src/PursLoader/Debug.purs diff --git a/docs/PursLoader/Debug.md b/docs/PursLoader/Debug.md new file mode 100644 index 0000000..824a9f8 --- /dev/null +++ b/docs/PursLoader/Debug.md @@ -0,0 +1,9 @@ +## Module PursLoader.Debug + +#### `debug` + +``` purescript +debug :: forall eff. String -> Eff (loader :: Loader | eff) Unit +``` + + diff --git a/package.json b/package.json index 4d1dff2..e1a79d6 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "dependencies": { "async": "^1.3.0", "chalk": "^1.1.0", + "debug": "^2.2.0", "loader-utils": "^0.2.6" } } 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 @@ +'use strict'; + +// module PursLoader.Debug + +var debug_ = require('debug')('purs-loader'); + +function debug(message) { + return function(){ + debug_(message); + }; +} +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 @@ +module PursLoader.Debug (debug) where + +import Prelude (Unit()) + +import Control.Monad.Eff (Eff()) + +import PursLoader.LoaderRef (Loader()) + +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 , resourcePath ) +import PursLoader.Debug (debug) import PursLoader.LoaderUtil (parseQuery) import PursLoader.Options (Options(..)) import PursLoader.Path (dirname, relative) @@ -47,6 +48,8 @@ loader ref source = do cacheable ref + debug "Invoke PureScript plugin compilation" + pluginContext.compile (compile callback) where pluginContext :: Plugin.Context (Effects eff) @@ -56,6 +59,8 @@ loader ref source = do compile callback error' { srcMap, ffiMap, graph } = do clearDependencies ref + either (const $ pure unit) (\a -> debug ("Adding PureScript dependency " ++ a)) name + addDependency ref (resourcePath ref) either (\err -> callback (Just err) "") id @@ -63,6 +68,7 @@ loader ref source = do where handle :: String -> Array String -> String -> Eff (Effects eff) Unit handle name' deps res = do + debug ("Adding PureScript transitive dependencies for " ++ name') addTransitive name' foreachE deps addTransitive callback (toMaybe error') res -- cgit v1.2.3