base

package
v0.0.0-...-93f0462 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package base logger notes: varied FOSS projects, gists, blogs etc inspired this effort to adapt ZAP and Lumberjack for OSFCI's base library. There are many proects to list and if someone can find a go package that closely represents all the functions here, please let us know.

Package base logger notes: same as zap.go

Index

Constants

View Source
const (
	//Debug for verbose logging
	Debug = "debug"
	//Info for info logging
	Info = "info"
	//Warn for warning logs
	Warn = "warn"
	//Error for error logs
	Error = "error"
	//Fatal is for logging fatal messages. The system shutsdown after logging the message.
	Fatal = "fatal"
)
View Source
const (
	//InstanceZapLogger for instance
	InstanceZapLogger int = iota
)

Variables

View Source
var MaxAge = 3600 * 24

MaxAge defines cookie expiration

View Source
var ProhibitedDomains string

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

CheckPasswordHash checks given password

func CheckURLExists

func CheckURLExists(request string) bool

CheckURLExists handles checks ia URL exists

func Debugf

func Debugf(format string, args ...interface{})

Debugf interface impl

func Errorf

func Errorf(format string, args ...interface{})

Errorf interface impl

func Fatalf

func Fatalf(format string, args ...interface{})

Fatalf interface impl

func GenerateAccountACKLink(length int) string

GenerateAccountACKLink generates account verification link

func GenerateAuthToken

func GenerateAuthToken(TokenType string, length int) string

GenerateAuthToken creates auth token for created user

func GetClientIP

func GetClientIP(r *http.Request) string

func HTTPDeleteRequest

func HTTPDeleteRequest(request string)

HTTPDeleteRequest handles Delete request to backend

func HTTPGetBody

func HTTPGetBody(r *http.Request) []byte

HTTPGetBody handles request body for redirects

func HTTPGetRequest

func HTTPGetRequest(request string) string

HTTPGetRequest handles some HTTP request Get request to the storage backend

func HTTPPutRequest

func HTTPPutRequest(request string, content []byte, contentType string) string

HTTPPutRequest handles Put request to the storage backend

func HashPassword

func HashPassword(password string) (string, error)

HashPassword gets hash from password

func Infof

func Infof(format string, args ...interface{})

Infof interface impl

func InitProhibitedIPs

func InitProhibitedIPs() error

func NewLogger

func NewLogger(config Configuration) error

NewLogger returns an instance of logger

func Panicf

func Panicf(format string, args ...interface{})

Panicf interface impl

func Request

func Request(method string, resURI string, Path string, Data string, content []byte, query string, Key string, SecretKey string) (*http.Response, error)

Request handler

func SendEmail

func SendEmail(email string, subject string, validationString string)

SendEmail provides email function for varied interactions

func UpdateProhibitedIPs

func UpdateProhibitedIPs(blockedIPs string)

func ValidateClientIP

func ValidateClientIP(req *http.Request) bool

func ValidateDomain

func ValidateDomain(userEmail string) bool

func Warnf

func Warnf(format string, args ...interface{})

Warnf interface impl

Types

type Configuration

type Configuration struct {
	EnableConsole     bool
	ConsoleJSONFormat bool
	ConsoleLevel      string
	EnableFile        bool
	FileJSONFormat    bool
	FileLevel         string
	FileLocation      string
}

Configuration stores the config for the logger

type Fields

type Fields map[string]interface{}

Fields Type to pass when we want to call WithFields for structured logging

type Logger

type Logger interface {
	//Debugf level interface
	Debugf(format string, args ...interface{})
	//Infof level interface
	Infof(format string, args ...interface{})
	//Warnf level interface
	Warnf(format string, args ...interface{})
	//Errorf level interface
	Errorf(format string, args ...interface{})
	//Fatalf level interface
	Fatalf(format string, args ...interface{})
	//Panic level interface
	Panicf(format string, args ...interface{})
}

Logger interface

var Zlog Logger

Zlog A global variable so that log functions can be directly accessed

type Prohibited

type Prohibited struct {
	// contains filtered or unexported fields
}
var ProhibitedIPs Prohibited

type User

type User struct {
	Nickname         string
	Password         string
	TokenType        string
	TokenAuth        string
	TokenSecret      string
	CreationDate     string
	Lastlogin        string
	Email            string
	Active           int
	ValidationString string
	Ports            string
	Server           string
}

User structure holds authorized users details

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL