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 --- src/PursLoader/Debug.js | 12 ++++++++++++ src/PursLoader/Debug.purs | 9 +++++++++ src/PursLoader/Loader.purs | 6 ++++++ 3 files changed, 27 insertions(+) create mode 100644 src/PursLoader/Debug.js create mode 100644 src/PursLoader/Debug.purs (limited to 'src') 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