@@ -3,6 +3,7 @@ module Kafka.Kafka
33 , Kafka
44 , KafkaConfig
55 , makeClient
6+ , LogLevel(..)
67 ) where
78
89import Prelude
@@ -11,6 +12,18 @@ import Data.Nullable (Nullable, toNullable)
1112
1213foreign import data Kafka :: Type
1314
15+
16+data LogLevel = LogNothing | LogDebug | LogInfo | LogWarn | LogError
17+
18+foreign import data InternalLogLevel :: Type
19+
20+foreign import internalLogNothing :: InternalLogLevel
21+
22+foreign import internalLogDebug :: InternalLogLevel
23+foreign import internalLogInfo:: InternalLogLevel
24+foreign import internalLogWarn :: InternalLogLevel
25+foreign import internalLogError :: InternalLogLevel
26+
1427type SaslConfig
1528 = { mechanism :: String
1629 , username :: String
@@ -22,6 +35,7 @@ type InternalKafkaConfig
2235 , brokers :: Array String
2336 , ssl :: Boolean
2437 , sasl :: Nullable SaslConfig
38+ , logLevel :: Nullable InternalLogLevel
2539 }
2640
2741type KafkaConfig
@@ -29,6 +43,7 @@ type KafkaConfig
2943 , brokers :: Array String
3044 , ssl :: Boolean
3145 , sasl :: Maybe SaslConfig
46+ , logLevel :: Maybe LogLevel
3247 }
3348
3449foreign import makeClientImpl :: InternalKafkaConfig -> Kafka
@@ -36,9 +51,17 @@ foreign import makeClientImpl :: InternalKafkaConfig -> Kafka
3651makeClient :: KafkaConfig -> Kafka
3752makeClient = toInternal >>> makeClientImpl
3853 where
54+
55+ toInternalLogLevel LogNothing = internalLogNothing
56+ toInternalLogLevel LogDebug = internalLogDebug
57+ toInternalLogLevel LogInfo = internalLogDebug
58+ toInternalLogLevel LogWarn = internalLogWarn
59+ toInternalLogLevel LogError = internalLogError
60+
3961 toInternal config =
4062 { clientId: config.clientId
4163 , brokers: config.brokers
4264 , ssl: config.ssl
4365 , sasl: toNullable config.sasl
66+ , logLevel : config.logLevel <#> toInternalLogLevel # toNullable
4467 }