
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
github.com/saurav-suman/logging-go
logging-go
?logging-go
supports log levels And you can publish log to rabbitMQ for now.
Logging libraries are like opinions, everyone needs one depends upon the need. You can add multiple parameters to the message for log, critical, info, debug, warn which will be transformed to a single string.
logging-go
different?Publish to RabbitMQ using a logging-go instantiated like so:
import (
logger "github.com/Saurav-Suman/logging-go"
)
package main
import (
logger "logging-go"
)
/*
ANSIC = "Mon Jan _2 15:04:05 2006"
UnixDate = "Mon Jan _2 15:04:05 MST 2006"
RubyDate = "Mon Jan 02 15:04:05 -0700 2006"
RFC822 = "02 Jan 06 15:04 MST"
RFC822Z = "02 Jan 06 15:04 -0700" // RFC822 with numeric zone
RFC850 = "Monday, 02-Jan-06 15:04:05 MST"
RFC1123 = "Mon, 02 Jan 2006 15:04:05 MST"
RFC1123Z = "Mon, 02 Jan 2006 15:04:05 -0700" // RFC1123 with numeric zone
RFC3339 = "2006-01-02T15:04:05Z07:00"
RFC3339Nano = "2006-01-02T15:04:05.999999999Z07:00"
Kitchen = "3:04PM"
// Handy time stamps.
Stamp = "Jan _2 15:04:05"
StampMilli = "Jan _2 15:04:05.000"
StampMicro = "Jan _2 15:04:05.000000"
StampNano = "Jan _2 15:04:05.000000000"
*/
type CustomResponse struct {
Success bool
StatusCode int
Message string
}
func main() {
log := logger.SystemLoggerConfig{
LoggerTimeFormat: "time.RFC3339",
RabbitmqURL: "amqp://guest:guest@127.0.0.1:5672/",
QueuePrefix: "ayopop",
QueueNames: logger.QueueCategory{
Api: "api",
Debug: "debug",
Info: "info",
Warn: "warning",
Error: "error",
Critical: "critical",
},
}
// You can create your custom request
var response types.CustomResponse
response.Success = true
response.StatusCode = 200
response.Message = "OK."
responseJson, err := json.Marshal(response)
if err != nil {
fmt.Println("Error while JSON marshal")
}
log.Info(string(responseJson), "Another message", "Another awesome message")
log.Critical("Divide by zero", "This is another message')
log.Info("Created", "since", 1990)
log.Api(logger.ApiLoggerFields{Ip: "192.168.0.1",
Url: "getRechargeData",
StatusCode: 200,
Request: "Name=saurav",
Method: "POST",
Headers: "",
Response: "Result=True",
Timestamp: "",
})
}
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.