packages feed

ethereum-analyzer-webui 3.2.0 → 3.3.0

raw patch · 5 files changed

+32/−37 lines, 5 files

Files

ethereum-analyzer-webui.cabal view
@@ -1,5 +1,5 @@ name:                ethereum-analyzer-webui-version:             3.2.0+version:             3.3.0 synopsis:            A web frontend for ethereum-analyzer homepage:            https://github.com/zchn/ethereum-analyzer license:             Apache-2.0@@ -21,7 +21,7 @@ source-repository this   type:     git   location: https://github.com/zchn/ethereum-analyzer-  tag:      v3.2.0+  tag:      v3.3.0   subdir:   ethereum-analyzer-webui  library
src/Ethereum/Analyzer/Web/API.hs view
@@ -17,16 +17,17 @@ import Protolude  import Data.Aeson-       (FromJSON(..), ToJSON(..), Value(..), object, (.=), (.:))+       (FromJSON(..), ToJSON(..), Value(..), (.:), (.=), object) import Data.Aeson.Types (typeMismatch) import qualified NeatInterpolation as NI import Servant.API-       ((:>), (:<|>)(..), Get, JSON, MimeRender(..), QueryParam, Raw)+       ((:<|>)(..), (:>), Get, JSON, MimeRender(..), QueryParam, Raw)  import Ethereum.Analyzer.Web.API.Internal (HTML)  -- | ethereum-analyzer API definition.-type API = Get '[ HTML] RootPage :<|> "users" :> Get '[ JSON] Users :<|> "ea" :> "dotcfg" :> QueryParam "code" Text :> Get '[ JSON] DotCfgResp :<|> "ea" :> "dotcfg2" :> QueryParam "code" Text :> Get '[ JSON] DotCfgResp+type API+   = Get '[ HTML] RootPage :<|> "users" :> Get '[ JSON] Users :<|> "ea" :> "dotcfg" :> QueryParam "code" Text :> Get '[ JSON] DotCfgResp :<|> "ea" :> "dotcfg2" :> QueryParam "code" Text :> Get '[ JSON] DotCfgResp  -- | Value-level representation of API. apiraw :: Proxy (API :<|> "web" :> Raw)
src/Ethereum/Analyzer/Web/Server/Handlers.hs view
@@ -13,10 +13,10 @@ import Control.Monad.Log (Severity, logInfo) import Ethereum.Analyzer.EVM import Ethereum.Analyzer.Web.API-       (API, RootPage(..), User(..), Users(..), DotCfgResp(..))+       (API, DotCfgResp(..), RootPage(..), User(..), Users(..)) import qualified Ethereum.Analyzer.Web.Server.Logging as Log import Servant-       (ServantErr, Server, (:<|>)(..), (:>), (:~>)(..), enter, Raw)+       ((:<|>)(..), (:>), (:~>)(..), Raw, ServantErr, Server, enter) import Servant.Utils.StaticFiles (serveDirectory) import Text.PrettyPrint.Leijen.Text (Doc, Pretty, text) @@ -33,14 +33,10 @@ -- -- See http://haskell-servant.readthedocs.io/en/stable/tutorial/Server.html#using-another-monad-for-your-handlers -- for the details.-toHandler-  :: Pretty msg-  => Severity -> (Handler msg :~> ExceptT ServantErr IO)+toHandler :: Pretty msg => Severity -> (Handler msg :~> ExceptT ServantErr IO) toHandler logLevel = Nat toHandler'   where-    toHandler'-      :: Pretty msg-      => Handler msg a -> ExceptT ServantErr IO a+    toHandler' :: Pretty msg => Handler msg a -> ExceptT ServantErr IO a     toHandler' = ExceptT . Log.withLogging logLevel . runExceptT  -- | Example endpoint.
src/Ethereum/Analyzer/Web/Server/Instrument.hs view
@@ -55,8 +55,8 @@         "The HTTP request latencies in microseconds."  -- | Instrument a WAI app with the default WAI metrics.-instrumentApp-  :: RequestDuration -- ^ The metric to instrument+instrumentApp ::+     RequestDuration -- ^ The metric to instrument   -> Text -- ^ The label used to identify this app   -> Wai.Application -- ^ The app to instrument   -> Wai.Application -- ^ The instrumented app@@ -79,8 +79,8 @@  -- | Instrument an app with Prometheus and export metrics from the configured -- handler.-prometheus-  :: PrometheusSettings -- ^ How we're going to use Prometheus+prometheus ::+     PrometheusSettings -- ^ How we're going to use Prometheus   -> RequestDuration -- ^ A metric to instrument with request information   -> Text -- ^ The label used to identify the app   -> Wai.Middleware@@ -98,8 +98,8 @@ metrics :: Wai.Application metrics = const respondWithMetrics -respondWithMetrics :: (Wai.Response -> IO Wai.ResponseReceived)-                   -> IO Wai.ResponseReceived+respondWithMetrics ::+     (Wai.Response -> IO Wai.ResponseReceived) -> IO Wai.ResponseReceived respondWithMetrics respond = do   content <- Prom.exportMetricsAsText   respond $ Wai.responseBuilder HTTP.status200 headers $ byteString content
src/Ethereum/Analyzer/Web/Server/Logging.hs view
@@ -14,36 +14,33 @@  import Control.Monad.Catch (MonadMask) import Control.Monad.Log-       (Handler, LoggingT, MonadLog, Severity(..), WithTimestamp(..),-        WithSeverity(..), defaultBatchingOptions, logMessage,+       (Handler, LoggingT, MonadLog, Severity(..), WithSeverity(..),+        WithTimestamp(..), defaultBatchingOptions, logMessage,         mapLogMessageM, renderWithSeverity, renderWithTimestamp,         runLoggingT, timestamp, withFDHandler) import Data.Time.Format        (defaultTimeLocale, formatTime, iso8601DateFormat) import Text.PrettyPrint.Leijen.Text (Doc, Pretty(..)) -type LogM msg m = LoggingT (WithSeverity msg) (LoggingT (WithTimestamp (WithSeverity msg)) m)+type LogM msg m+   = LoggingT (WithSeverity msg) (LoggingT (WithTimestamp (WithSeverity msg)) m)  -- | Take a bunch of logs with severity and print them to stdout with timestamps.-withLogging-  :: (MonadMask m, MonadIO m, Pretty msg)-  => Severity -> LogM msg m a -> m a+withLogging ::+     (MonadMask m, MonadIO m, Pretty msg) => Severity -> LogM msg m a -> m a withLogging severityThreshold body =   withFDHandler defaultBatchingOptions stdout 0.4 80 $ \stdoutHandler ->     runLoggingT       (withTimestamps body)       (printLogs severityThreshold stdoutHandler) -withTimestamps-  :: (MonadIO m, MonadLog (WithTimestamp msg) m)-  => LoggingT msg m a -> m a+withTimestamps ::+     (MonadIO m, MonadLog (WithTimestamp msg) m) => LoggingT msg m a -> m a withTimestamps = mapLogMessageM timestamp  type Keyword = Text -fromKeyword-  :: Alternative m-  => Keyword -> m Severity+fromKeyword :: Alternative m => Keyword -> m Severity fromKeyword "emerg" = pure Emergency fromKeyword "alert" = pure Alert fromKeyword "crit" = pure Critical@@ -66,9 +63,12 @@ toKeyword Informational = "info" toKeyword Debug = "debug" -printLogs-  :: (Pretty a, MonadIO m)-  => Severity -> Handler m Doc -> WithTimestamp (WithSeverity a) -> m ()+printLogs ::+     (Pretty a, MonadIO m)+  => Severity+  -> Handler m Doc+  -> WithTimestamp (WithSeverity a)+  -> m () printLogs severityThreshold handler message =   when (severityThreshold >= msgSeverity (discardTimestamp message)) $   handler . renderWithTimestamp timeFormatter (renderWithSeverity pretty) $@@ -78,7 +78,5 @@     timeFormat = iso8601DateFormat (Just "%H:%M:%S.%q")  -- | Convenience method to log with severity.-log-  :: MonadLog (WithSeverity a) m-  => Severity -> a -> m ()+log :: MonadLog (WithSeverity a) m => Severity -> a -> m () log severity msg' = logMessage (WithSeverity severity msg')