tpiperatgod opened a new issue, #16928:
URL: https://github.com/apache/pulsar/issues/16928

   **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_level` argument to `python_instance_main.py` to pass in 
the logging level, and add the following handle logic to `log.py` to set the 
logging level for each handlers.
   
     ```python
     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 the `LOGGING_LEVEL` environment variable 
in `log.go`, , and finally set the logging level.
   
     ```go
     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.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to