pitlog

package module
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: MIT Imports: 14 Imported by: 0

README

Build Status

Testing Machine:

- MacOs 12.6.7
- go version go1.23.1 darwin/amd64 
Pitlog: A Logging Middleware for Echo Framework

Pitlog is a logging middleware designed to integrate with the Echo framework in Go. It provides structured logging for both requests and responses with support for masking sensitive fields.

Installation

To install the package, use go get:

go get github.com/fitra-besari/pitlog

for example you can see on directory /example and you can run go mod download and go run main.go, will be run on port 8080 you can hit localhost:8080/ping and you have see log api on your terminal and you config file on root repository on your project.

parameters

you can config application name on log

appName := "ExampleApp"

you can config application version on log

appVersion := "1.0.0"

you can config application level on log, if you use production you will be get minimal indentation on log

appLevel := "development"

you can config directory of log file , will be on dir ./logs from root repository

logDir := "logs"

you can config view log on your terminal console for enable log on console ,default will be outo enable on log file only . optional value is "1" or "0"

enableLogConsole := "1"

you can config border of log view . optional value is "1" or "0" useSeparate := "1"

if you set "1" you will be see your log data on object view, if use "0" will be on string view

objectView := "1"

Note

  • jika ada kendala di invite project github / postman mohon hubungi afitra - 085230010042

http://apitoong.com

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IN_pitlog_base

type IN_pitlog_base interface {
	Api_log_middleware(ech *echo.Echo, sensitive []string)
	Make_log_string(request_id string, status int, title string, message string)
	Make_log_string_to_object(request_id string, status int, title string, message string)
	Make_log_object(request_id string, status int, title string, object interface{})
	Make_log_object_to_string(request_id string, status int, title string, object interface{})
}

func New_pitlog

func New_pitlog(payload Pitlog_payload) (IN_pitlog_base, error)

type Log_model

type Log_model struct {
	Mode   string
	Detail string
	Header string
	Body   string
}

type Pit_json_message

type Pit_json_message struct {
	Request_id string `json:"request_id"`
	Status     string `json:"status"`
	Title      string `json:"title"`
	Message    string `json:"message"`
	Date       string `json:"date"`
}

type Pitlog_base

type Pitlog_base struct {
	// contains filtered or unexported fields
}

func (*Pitlog_base) Api_log_middleware

func (DI *Pitlog_base) Api_log_middleware(ech *echo.Echo, sensitive []string)

func (*Pitlog_base) Make_log_object

func (DI *Pitlog_base) Make_log_object(request_id string, status int, title string, object interface{})

func (*Pitlog_base) Make_log_object_to_string added in v1.0.4

func (DI *Pitlog_base) Make_log_object_to_string(request_id string, status int, title string, object interface{})

func (*Pitlog_base) Make_log_string

func (DI *Pitlog_base) Make_log_string(request_id string, status int, title string, message string)

func (*Pitlog_base) Make_log_string_to_object added in v1.0.4

func (DI *Pitlog_base) Make_log_string_to_object(request_id string, status int, title string, message string)

type Pitlog_payload added in v1.0.5

type Pitlog_payload struct {
	App_name           string
	App_version        string
	App_level          string
	Log_dir            string
	Enable_log_console string
	Use_separate       string
}

type Request_detail

type Request_detail struct {
	Url          string `json:"url"`
	Method       string `json:"method"`
	Request_id   string `json:"request_id"`
	Request_date string `json:"request_date"`
	Ip           string `json:"ip"`
	Api_type     string `json:"api_type"`
	Channel      string `json:"channel"`
	Timezone     string `json:"timezone"`
	Bytes_in     string `json:"bytes_in"`
	App_level    string `json:"App_level"`
	App_version  string `json:"App_version"`
}

type Request_logger

type Request_logger struct {
	Request_id string      `json:"requestID,omitempty"`
	Payload    interface{} `json:"payload,omitempty"`
}

type Response_detail

type Response_detail struct {
	Request_detail
	Bytes_out     string        `json:"bytes_out"`
	Error         string        `json:"error"`
	Latency       time.Duration `json:"latency"`
	Latency_human string        `json:"latency_human"`
	Status        int           `json:"status"`
}

Jump to

Keyboard shortcuts

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