logs

package
v0.0.0-...-81c02da Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: Apache-2.0 Imports: 8 Imported by: 51

Documentation

Overview

Package logs ...

Index

Constants

This section is empty.

Variables

Log is an instance of logrus.Entry. This instance should be initialized at the start of the each service and will be used for logging

Functions

func Adorn

func Adorn(m logrus.Fields)

Adorn adds the fields to Log variable

func AuditLog

func AuditLog(l *Logging, ctx iris.Context, reqBody map[string]interface{}) *logrus.Entry

AuditLog is used for generating audit logs in syslog format for each request this function logs an info for successful operation and error for failure operation properties logged are prival, time, host, username, roleid, request method, resource, requestbody, responsecode and message

func AuthLog

func AuthLog(ctx context.Context) *logrus.Entry

AuthLog is used for generating security logs in syslog format for each request this function logs an info for successful operation and warning for failure auth operation properties logged are prival, time, username, roleid and message

func LogWithFields

func LogWithFields(ctx context.Context) *logrus.Entry

LogWithFields add fields to log

func MaskRequestBody

func MaskRequestBody(reqBody map[string]interface{}) string

MaskRequestBody function masking the request body, making password as null

func SetFormatter

func SetFormatter(format LogFormat)

SetFormatter set the format for logging

Types

type LogFormat

type LogFormat uint32

LogFormat is custom type created for the log formats supported by ODIM

const (
	SyslogFormat LogFormat = iota
	JSONFormat
)

log formats supported by ODIM

func ParseLogFormat

func ParseLogFormat(format string) (LogFormat, error)

ParseLogFormat takes a string level and returns the log format.

func (LogFormat) MarshalText

func (format LogFormat) MarshalText() ([]byte, error)

MarshalText will validate the log format and return the corresponding string

func (LogFormat) String

func (format LogFormat) String() string

Convert the log format to a string.

func (*LogFormat) UnmarshalText

func (format *LogFormat) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type Logging

type Logging struct {
	GetUserDetails func(context.Context, string) (string, string, error)
}

Logging contains method signatures of helper functions for logging

type SysLogFormatter

type SysLogFormatter struct{}

SysLogFormatter implements logrus Format interface. It provides a formatter for odim in syslog format

func (*SysLogFormatter) Format

func (f *SysLogFormatter) Format(entry *logrus.Entry) ([]byte, error)

Format renders a log in syslog format

Jump to

Keyboard shortcuts

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