Giter Club home page Giter Club logo

logging's People

Contributors

adriancable avatar at-wat avatar backkem avatar edaniels avatar mjmac avatar pionbot avatar sean-der avatar stv0g avatar wdouglass avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

logging's Issues

Performance concerns

pion/logging has been really useful for me, and using a lot for debugging.
@Sean-Der expressed his concern about its performance, and I'd agree, that is a concern...

For example, if you have this statement:

	logger.Debug("received data %s", pkt.String())

It looks alright, and it is just a debug log that only prints out when it is enabled with PION_LOG_DEBUG...

BUT! What if pkt.String() was an expensive routine? This is evaluated no matter what, consuming CPU time in production as well... Unfortunately, go has no compile-time options like C has (#ifdef etc.)

One obvious solution would be to use a callback like this:

	logger.Debug(func (p *LoggerPad) {
		p.Format("received data %s", pkt.String())
	})

The Debug function can be designed in a way that the callback function passed in it won't be called if it is not set to DEBUG level. You will need to type a lot more but it saves a lot of CPU time!

PIONS_LOG_DISABLED

Summary

Provide a way to disable logging completely.

Motivation

Default logging is currently set to ERROR. In order to disable logging completely, we need to use API to configure a custom logger factory.

Describe alternatives you've considered

Set the default logging level to "disabled"

If we were to keep the default logging level as Error and allow users to use env vars by default, then we should provide a way to disable the logging completely with the env var.

diff --git a/logger.go b/logger.go
index d3c0156..3e07cdd 100644
--- a/logger.go
+++ b/logger.go
@@ -181,11 +181,12 @@ func NewDefaultLoggerFactory() *DefaultLoggerFactory {
        factory.Writer = os.Stdout

        logLevels := map[string]LogLevel{
-               "ERROR": LogLevelError,
-               "WARN":  LogLevelWarn,
-               "INFO":  LogLevelInfo,
-               "DEBUG": LogLevelDebug,
-               "TRACE": LogLevelTrace,
+               "DISABLED": LogLevelDisabled,
+               "ERROR":    LogLevelError,
+               "WARN":     LogLevelWarn,
+               "INFO":     LogLevelInfo,
+               "DEBUG":    LogLevelDebug,
+               "TRACE":    LogLevelTrace,
        }

        for name, level := range logLevels {

Ideally, we should set the default level to "Disabled" IMO. (keep the current default)

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Dependency Dashboard

This issue provides visibility into Renovate updates and their statuses. Learn more

This repository currently has no open or pending branches.


  • Check this box to trigger a request for Renovate to run again on this repository

No globals

Summary

Avoid using globals & init and enable the corresponding linters.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.