diff --git a/conf.sample.yml b/conf.sample.yml index 31ba6d5..d410988 100644 --- a/conf.sample.yml +++ b/conf.sample.yml @@ -2,7 +2,7 @@ ### dtm can be run without any config. ### all config in this file is optional. the default value is as specified in each line ### all configs can be specified from env. for example: -### Store.MaxOpenConns can also specified from env: STORE_MAX_OPEN_CONNS +### MicroService.EndPoint => MICRO_SERVICE_END_POINT ##################################################################### # Store: # specify which engine to store trans status @@ -49,4 +49,5 @@ # RetryInterval: 10 # the subtrans branch will be retried after this interval # LogLevel: 'info' # default: info. can be debug|info|warn|error - +# HttpPort: 36789 +# GrpcPort: 36790 diff --git a/dtmcli/logger/log.go b/dtmcli/logger/log.go index 81466b3..5fb0a03 100644 --- a/dtmcli/logger/log.go +++ b/dtmcli/logger/log.go @@ -13,7 +13,7 @@ import ( var logger Logger = nil func init() { - InitLog("info") + InitLog(os.Getenv("LOG_LEVEL")) } // Logger logger interface diff --git a/dtmsvr/config/config_utils.go b/dtmsvr/config/config_utils.go index 3d37b0c..f588eee 100644 --- a/dtmsvr/config/config_utils.go +++ b/dtmsvr/config/config_utils.go @@ -49,9 +49,12 @@ func loadFromEnvInner(prefix string, conf reflect.Value, defaultValue string) { func toUnderscoreUpper(key string) string { key = strings.Trim(key, "_") + matchLastCap := regexp.MustCompile("([A-Z])([A-Z][a-z])") + s2 := matchLastCap.ReplaceAllString(key, "${1}_${2}") + matchFirstCap := regexp.MustCompile("([a-z])([A-Z]+)") - s2 := matchFirstCap.ReplaceAllString(key, "${1}_${2}") - // logger.Debugf("loading from env: %s", strings.ToUpper(s2)) + s2 = matchFirstCap.ReplaceAllString(s2, "${1}_${2}") + // logger.Infof("loading from env: %s", strings.ToUpper(s2)) return strings.ToUpper(s2) }