code: func NewHandler(config *types.AccessLog) (*Handler, error) {
  	file := os.Stdout
  	if len(config.FilePath) > 0 {
  		f, err := openAccessLogFile(config.FilePath)
  		if err != nil {
  			return nil, fmt.Errorf("error opening access log file: %s", err)
  		}
  		file = f
  	}
  	logHandlerChan := make(chan handlerParams, config.BufferingSize)
  
  	var formatter logrus.Formatter
  
  	switch config.Format {
  	case CommonFormat:
  		formatter = new(CommonLogFormatter)
  	case JSONFormat:
  		formatter = new(logrus.JSONFormatter)
  	default:
  		return nil, fmt.Errorf("unsupported access log format: %s", config.Format)
  	}
  
  	logger := &logrus.Logger{
  		Out:       file,
  		Formatter: formatter,
  		Hooks:     make(logrus.LevelHooks),
  		Level:     logrus.InfoLevel,
  	}
  
  	logHandler := &Handler{
  		config:         config,
  		logger:         logger,
  		file:           file,
  		logHandlerChan: logHandlerChan,
  	}
  
  	if config.Filters != nil {
  		if httpCodeRanges, err := types.NewHTTPCodeRanges(config.Filters.StatusCodes); err != nil {
  			log.WithoutContext().Errorf("Failed to create new HTTP code ranges: %s", err)
  		} else {
  			logHandler.httpCodeRanges = httpCodeRanges
  		}
  	}
  
  	if config.BufferingSize > 0 {
  		logHandler.wg.Add(1)
  		go func() {
  			defer logHandler.wg.Done()
  			for handlerParams := range logHandler.logHandlerChan {
  				logHandler.logTheRoundTrip(handlerParams.logDataTable, handlerParams.crr, handlerParams.crw)
  			}
  		}()
  	}
  
  	return logHandler, nil
  }
docs: // NewHandler creates a new Handler.