From: Michael Orlitzky Date: Sun, 29 Dec 2013 00:06:43 +0000 (-0500) Subject: Move the Report, Logging, and Terminal modules into their own namespace. X-Git-Tag: 0.0.4~6 X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Fhtsn.git;a=commitdiff_plain;h=a4eb5f096c486cb94b1e8a25de7bc16879cab6e5 Move the Report, Logging, and Terminal modules into their own namespace. --- diff --git a/htsn.cabal b/htsn.cabal index a25b7e9..72c22be 100644 --- a/htsn.cabal +++ b/htsn.cabal @@ -230,10 +230,10 @@ executable htsn Configuration ExitCodes FeedHosts - Logging + Network.Services.TSN.Logging OptionalConfiguration - Report - Terminal + Network.Services.TSN.Report + Network.Services.TSN.Terminal Unix Xml diff --git a/makefile b/makefile index 45ed838..d1b5052 100644 --- a/makefile +++ b/makefile @@ -1,19 +1,23 @@ BIN = dist/build/htsn/htsn TESTSUITE_BIN = dist/build/testsuite/testsuite +SRCS := $(shell find src/ -type f -name '*.hs') +TEST_SRCS := $(shell find test/ -type f -name '*.hs') .PHONY : dist hlint -$(BIN): src/*.hs +$(BIN): $(SRCS) runghc Setup.hs clean runghc Setup.hs configure --user --prefix=/ runghc Setup.hs build -profile: src/*.hs +profile: $(SRCS) runghc Setup.hs clean - runghc Setup.hs configure --user --enable-executable-profiling --prefix=/ + runghc Setup.hs configure --user \ + --enable-executable-profiling \ + --prefix=/ runghc Setup.hs build -doc: *.cabal src/*.hs +doc: *.cabal $(SRCS) runghc Setup.hs configure --user --prefix=/ runghc Setup.hs hscolour --executables runghc Setup.hs haddock --internal \ @@ -26,7 +30,7 @@ clean: rm -f *.xml rm -rf tmp -$(TESTSUITE_BIN): src/*.hs test/TestSuite.hs +$(TESTSUITE_BIN): $(SRCS) $(TEST_SRCS) runghc Setup.hs configure --user --enable-tests --prefix=/ runghc Setup.hs build diff --git a/src/Main.hs b/src/Main.hs index ece44a8..a06bd23 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -38,16 +38,16 @@ import ExitCodes ( exit_no_username, exit_pidfile_exists ) import FeedHosts ( FeedHosts(..) ) -import Logging ( init_logging ) +import Network.Services.TSN.Logging ( init_logging ) import qualified OptionalConfiguration as OC ( OptionalConfiguration(..), from_rc ) -import Report ( +import Network.Services.TSN.Report ( report_debug, report_info, report_warning, report_error ) -import Terminal ( display_sent ) +import Network.Services.TSN.Terminal ( display_sent ) import Xml ( parse_xmlfid ) import Unix ( full_daemonize ) diff --git a/src/Logging.hs b/src/Network/Services/TSN/Logging.hs similarity index 98% rename from src/Logging.hs rename to src/Network/Services/TSN/Logging.hs index 63101c6..a20a897 100644 --- a/src/Logging.hs +++ b/src/Network/Services/TSN/Logging.hs @@ -1,4 +1,4 @@ -module Logging ( +module Network.Services.TSN.Logging ( init_logging, log_debug, log_error, diff --git a/src/Report.hs b/src/Network/Services/TSN/Report.hs similarity index 91% rename from src/Report.hs rename to src/Network/Services/TSN/Report.hs index 925a018..2423352 100644 --- a/src/Report.hs +++ b/src/Network/Services/TSN/Report.hs @@ -1,19 +1,19 @@ -- | Convenience functions for reporting (display and/or logging) -- status messages. -- -module Report ( +module Network.Services.TSN.Report ( report_debug, report_error, report_info, report_warning ) where -import Logging ( +import Network.Services.TSN.Logging ( log_debug, log_error, log_info, log_warning ) -import Terminal ( +import Network.Services.TSN.Terminal ( display_debug, display_error, display_info, diff --git a/src/Terminal.hs b/src/Network/Services/TSN/Terminal.hs similarity index 98% rename from src/Terminal.hs rename to src/Network/Services/TSN/Terminal.hs index 064c5ff..e24d23c 100644 --- a/src/Terminal.hs +++ b/src/Network/Services/TSN/Terminal.hs @@ -1,4 +1,4 @@ -module Terminal ( +module Network.Services.TSN.Terminal ( display_debug, display_error, display_info, diff --git a/src/OptionalConfiguration.hs b/src/OptionalConfiguration.hs index 33ca3d9..8790ca0 100644 --- a/src/OptionalConfiguration.hs +++ b/src/OptionalConfiguration.hs @@ -35,8 +35,7 @@ import System.IO.Error ( catchIOError ) import System.Log ( Priority(..) ) import FeedHosts ( FeedHosts(..) ) -import Logging ( log_error ) -- Can't import report_error from Main -import Terminal ( display_error ) -- 'cause of circular imports. +import Network.Services.TSN.Report ( report_error ) -- Derive standalone instances of Data and Typeable for Priority. This @@ -145,12 +144,10 @@ instance DCT.Configured Priority where from_rc :: IO OptionalConfiguration from_rc = do etc <- catchIOError getSysconfDir (\e -> do - display_error (show e) - log_error (show e) + report_error (show e) return "/etc") home <- catchIOError getHomeDirectory (\e -> do - display_error (show e) - log_error (show e) + report_error (show e) return "$(HOME)") let global_config_path = etc "htsnrc" let user_config_path = home ".htsnrc" diff --git a/src/Unix.hs b/src/Unix.hs index 96ec79a..b6990d2 100644 --- a/src/Unix.hs +++ b/src/Unix.hs @@ -31,8 +31,8 @@ import Configuration ( Configuration( pidfile, run_as_group, run_as_user )) -import Logging ( log_info, log_error ) -import Terminal ( display_error ) +import Network.Services.TSN.Logging ( log_info, log_error ) +import Network.Services.TSN.Terminal ( display_error ) -- | Retrieve the uid associated with the given system user name. We -- take a Maybe String as an argument so the user name can be passed