-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
Is your feature request related to a problem? Please describe.
Currently, if the user wants to output more logging level logs other than INFO, it should provide the log settings for different pulsar function runtimes.
Describe the solution you'd like
-
Python functions
Add the
--logging_levelargument topython_instance_main.pyto pass in the logging level, and add the following handle logic tolog.pyto set the logging level for each handlers.def init_logger(level, logfile, logging_config_file): global Log # get log file location for function instance os.environ['LOG_FILE'] = logfile logging.config.fileConfig(logging_config_file) Log = logging.getLogger() # the priority of `level` is higher than `logging_config_file` if level != "": Log.setLevel(level) # set logging level for each handler for h in Log.handlers: h.setLevel(level)
-
Go functions
Pass in the logging level via environment variable, such as setting
LOGGING_LEVEL, then add parsing of theLOGGING_LEVELenvironment variable inlog.go, , and finally set the logging level.const ( // environment variable for custom logging level logLevelEnvName = "LOGGING_LEVEL" defaultLogLevel = log.InfoLevel defaultLogTimeFormat = "2006/01/02 15:04:05.000" ) func init() { log.SetLevel(defaultLogLevel) // lookup and parse the logLevel variable if logLevelStr, exist := os.LookupEnv(logLevelEnvName); exist { if logLevel, err := log.ParseLevel(logLevelStr); err == nil { log.SetLevel(logLevel) } } log.AddHook(&contextHook{}) log.SetFormatter(&TextFormatter{}) }
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.