
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
devnw.com/alog
Installation:
go get -u go.devnw.com/alog
is an implementation of a fully concurrent non-IO blocking log library. Internally messages are routed through a number of subscribed destinations consisting of destination log levels, timezone formatting strings and an io.Writer for the destination to be written to.
The globally available functions utilize a singleton implementation of a global logger that is initialized when the package is loaded. This global logger utilizes os.Stdout for INFO, DEBUG, TRACE, WARN, CUSTOM logs, and os.Stderr for ERROR, CRITICAL, FATAL as defined in the method Standard()
The global logger singleton can be overridden using the "Global" method passing in the proper parameters as required by your use case.
If you prefer to use a non-global singleton logger you can use the "New" method to create a new logger which implements the alog packages "Logger" interface which can be passed throughout an application as a logger.
Each log level has an associated function:
c(channel) functions are special methods in the logger that rather than being called
directly are passed a channel which receives logs into the logger in a
concurrent manner without direct calls to the c(channel) function
again afterwards.
These methods are particularly useful for applications where the overhead of
a logger in concurrent actions is a particular nuisance. For these cases the
c(channel) functions are a perfect use case. Each log level supports it's own
c(channel) function.
This library currently support two log formatting types
{
"prefix":"PREFIX",
"type":"ERROR",
"timestamp":"2020-03-01T16:21:28-06:00",
"error":"Error Message",
"messages":["Log Message 1", "Log Message 2"]
}
Global Usage:
alog.Println("info log")
alog.Debugln(err, "debug log")
alog.Traceln(err, "trace log")
alog.Warnln(err, "warn log")
alog.Errorln(err, "err log")
alog.Critln(err, "critcal log")
alog.Fatalln(err, "fatal log")
alog.Customln("CUSTOM", err, "debug log")
For applications that want to ensure log completeness using alog
execute
alog.Wait(bool)
when cleaning up your application so that the logger can
correctly cleanup any lingering channels and Go routines. The boolean
parameter let's the wait method know if you want to also close the logger internally.
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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.