mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-08-17 12:00:29 +03:00
Make the logger take a list of properties
This commit is contained in:
parent
689081b035
commit
4710c132d4
@ -1,11 +1,13 @@
|
||||
module Review.Logger exposing (Logger, fromFn, log, none)
|
||||
|
||||
import Json.Encode as Encode
|
||||
|
||||
|
||||
type Logger
|
||||
= Logger (String -> String)
|
||||
= Logger (List ( String, Encode.Value ) -> List ( String, Encode.Value ))
|
||||
|
||||
|
||||
fromFn : (String -> String) -> Logger
|
||||
fromFn : (List ( String, Encode.Value ) -> List ( String, Encode.Value )) -> Logger
|
||||
fromFn =
|
||||
Logger
|
||||
|
||||
@ -15,6 +17,6 @@ none =
|
||||
Logger identity
|
||||
|
||||
|
||||
log : Logger -> String -> a -> a
|
||||
log : Logger -> List ( String, Encode.Value ) -> a -> a
|
||||
log (Logger logFn) message data =
|
||||
always data <| logFn message
|
||||
|
@ -24,6 +24,7 @@ process like the CLI.
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Elm.Syntax.Range exposing (Range)
|
||||
import Json.Encode as Encode
|
||||
import Review.Logger as Logger
|
||||
import Review.Options.Internal as Internal exposing (ReviewOptionsInternal(..))
|
||||
|
||||
@ -59,7 +60,7 @@ withDataExtraction extract (ReviewOptionsInternal reviewOptions) =
|
||||
|
||||
{-| Add a logger.
|
||||
-}
|
||||
withLogger : Maybe (String -> String) -> ReviewOptions -> ReviewOptions
|
||||
withLogger : Maybe (List ( String, Encode.Value ) -> List ( String, Encode.Value )) -> ReviewOptions -> ReviewOptions
|
||||
withLogger maybeLogger (ReviewOptionsInternal reviewOptions) =
|
||||
ReviewOptionsInternal
|
||||
{ reviewOptions
|
||||
|
@ -6143,30 +6143,24 @@ isInSourceDirectories (Metadata metadata) =
|
||||
-- LOGS
|
||||
|
||||
|
||||
startedRule : String -> String
|
||||
startedRule : String -> List ( String, Encode.Value )
|
||||
startedRule name =
|
||||
Encode.object
|
||||
[ ( "type", Encode.string "rule-start" )
|
||||
, ( "ruleName", Encode.string name )
|
||||
]
|
||||
|> Encode.encode 0
|
||||
[ ( "type", Encode.string "rule-start" )
|
||||
, ( "ruleName", Encode.string name )
|
||||
]
|
||||
|
||||
|
||||
endedRule : String -> String
|
||||
endedRule : String -> List ( String, Encode.Value )
|
||||
endedRule name =
|
||||
Encode.object
|
||||
[ ( "type", Encode.string "rule-end" )
|
||||
, ( "ruleName", Encode.string name )
|
||||
]
|
||||
|> Encode.encode 0
|
||||
[ ( "type", Encode.string "rule-end" )
|
||||
, ( "ruleName", Encode.string name )
|
||||
]
|
||||
|
||||
|
||||
fixedError : FixedErrors -> { ruleName : String, filePath : String } -> String
|
||||
fixedError : FixedErrors -> { ruleName : String, filePath : String } -> List ( String, Encode.Value )
|
||||
fixedError fixedErrors data =
|
||||
Encode.object
|
||||
[ ( "type", Encode.string "apply-fix" )
|
||||
, ( "ruleName", Encode.string data.ruleName )
|
||||
, ( "filePath", Encode.string data.filePath )
|
||||
, ( "count", Encode.int (FixedErrors.count fixedErrors) )
|
||||
]
|
||||
|> Encode.encode 0
|
||||
[ ( "type", Encode.string "apply-fix" )
|
||||
, ( "ruleName", Encode.string data.ruleName )
|
||||
, ( "filePath", Encode.string data.filePath )
|
||||
, ( "count", Encode.int (FixedErrors.count fixedErrors) )
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user