github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/logconfig/openvpnlog.go (about)

     1  /*
     2   * Copyright (C) 2019 The "MysteriumNetwork/node" Authors.
     3   *
     4   * This program is free software: you can redistribute it and/or modify
     5   * it under the terms of the GNU General Public License as published by
     6   * the Free Software Foundation, either version 3 of the License, or
     7   * (at your option) any later version.
     8   *
     9   * This program is distributed in the hope that it will be useful,
    10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12   * GNU General Public License for more details.
    13   *
    14   * You should have received a copy of the GNU General Public License
    15   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    16   */
    17  
    18  package logconfig
    19  
    20  import (
    21  	"fmt"
    22  	"strings"
    23  
    24  	"github.com/rs/zerolog/log"
    25  )
    26  
    27  type zerologOpenvpnLogger struct {
    28  }
    29  
    30  // Error logs go-openvpn error.
    31  func (l zerologOpenvpnLogger) Error(args ...interface{}) {
    32  	strs := make([]string, len(args))
    33  	for i, v := range args {
    34  		strs[i] = fmt.Sprint(v)
    35  	}
    36  	log.Error().Msg(strings.Join(strs, " "))
    37  }
    38  
    39  // Warn logs go-openvpn warning.
    40  func (l zerologOpenvpnLogger) Warn(args ...interface{}) {
    41  	strs := make([]string, len(args))
    42  	for i, v := range args {
    43  		strs[i] = fmt.Sprint(v)
    44  	}
    45  	log.Warn().Msg(strings.Join(strs, " "))
    46  }
    47  
    48  // Info logs go-openvpn informational message.
    49  func (l zerologOpenvpnLogger) Info(args ...interface{}) {
    50  	strs := make([]string, len(args))
    51  	for i, v := range args {
    52  		strs[i] = fmt.Sprint(v)
    53  	}
    54  	log.Info().Msg(strings.Join(strs, " "))
    55  }
    56  
    57  // Debug logs go-openvpn debug message.
    58  func (l zerologOpenvpnLogger) Debug(args ...interface{}) {
    59  	strs := make([]string, len(args))
    60  	for i, v := range args {
    61  		strs[i] = fmt.Sprint(v)
    62  	}
    63  	log.Debug().Msg(strings.Join(strs, " "))
    64  }
    65  
    66  // Trace logs go-openvpn trace message.
    67  func (l zerologOpenvpnLogger) Trace(args ...interface{}) {
    68  	strs := make([]string, len(args))
    69  	for i, v := range args {
    70  		strs[i] = fmt.Sprint(v)
    71  	}
    72  	log.Trace().Msg(strings.Join(strs, " "))
    73  }