logrus | Structured , pluggable logging for Go

 by   sirupsen Go Version: v1.9.0 License: MIT

kandi X-RAY | logrus Summary

kandi X-RAY | logrus Summary

logrus is a Go library typically used in Logging applications. logrus has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.

Logrus is a structured logger for Go (golang), completely API compatible with the standard library logger. Logrus is in maintenance-mode. We will not be introducing new features. It's simply too hard to do in a way that won't break many people's projects, which is the last thing you want from your Logging library (again...). This does not mean Logrus is dead. Logrus will continue to be maintained for security, (backwards compatible) bug fixes, and performance (where we are limited by the interface). I believe Logrus' biggest contribution is to have played a part in today's widespread use of structured logging in Golang. There doesn't seem to be a reason to do a major, breaking iteration into Logrus V2, since the fantastic Go community has built those independently. Many fantastic alternatives have sprung up. Logrus would look like those, had it been re-designed with what we know about structured logging in Go today. Check out, for example, Zerolog, Zap, and Apex. Seeing weird case-sensitive problems? It's in the past been possible to import Logrus as both upper- and lower-case. Due to the Go package environment, this caused issues in the community and we needed a standard. Some environments experienced problems with the upper-case variant, so the lower-case was decided. Everything using logrus will need to use the lower-case: github.com/sirupsen/logrus. Any package that isn't, should be changed. To fix Glide, see these comments. For an in-depth explanation of the casing issue, see this comment.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              logrus has a medium active ecosystem.
              It has 22774 star(s) with 2242 fork(s). There are 319 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 3 open issues and 661 have been closed. On average issues are closed in 148 days. There are 65 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of logrus is v1.9.0

            kandi-Quality Quality

              logrus has 0 bugs and 0 code smells.

            kandi-Security Security

              logrus has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              logrus code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              logrus is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              logrus releases are available to install and integrate.
              Installation instructions are not available. Examples and code snippets are available.
              It has 4264 lines of code, 365 functions and 46 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of logrus
            Get all kandi verified functions for this library.

            logrus Key Features

            No Key Features are available at this moment for logrus.

            logrus Examples and Code Snippets

            No Code Snippets are available at this moment for logrus.

            Community Discussions

            QUESTION

            Pgxpool returns "pool closed" error on Scan
            Asked 2022-Feb-25 at 01:02

            I'm trying to implement pgxpool in a new go app. I keep getting a "pool closed" error after attempting a scan into a struct.

            The pgx logger into gives me this after connecting. I thought the pgxpool was meant to remain open.

            {"level":"info","msg":"closed connection","pid":5499,"time":"2022-02-24T16:36:33+10:30"}

            Here is my router code

            ...

            ANSWER

            Answered 2022-Feb-25 at 01:02

            It appears that you are doing something like the following:

            Source https://stackoverflow.com/questions/71248378

            QUESTION

            aws-sdk-go-v2 custom logger
            Asked 2022-Jan-29 at 10:55

            With v1 of the SDK i could use logrus for my custom logger, like:

            ...

            ANSWER

            Answered 2022-Jan-29 at 10:55

            It seems that sdk v2 offers a func wrapper to satisfy logging.logger:

            Source https://stackoverflow.com/questions/70904369

            QUESTION

            Content of go.sum and modules really used by a go application
            Asked 2022-Jan-12 at 17:09

            I'm trying to compare the behavior of go mod tidy (and the resulting content of go.sum) to the output of go list -m all. Reading the docs, I understand go.sum contains the whole list of dependent modules declared in go.mod and in dependencies' go.mod files, go list -m all shows the modules really loaded during the execution. As an example, an application including logrus and prometheus like this:

            go.mod

            ...

            ANSWER

            Answered 2022-Jan-12 at 17:09

            Yes, it correct to say the modules really "used" by the application are listed by go list -m all (as per documentation you provided the link of). By "used", it means the package selected at build time for the compilation of the go code of your application.

            We had a similar issue with a static analysis tool and we had to change the configuration to use the output of go list -m all (dumped in a file) instead of go.sum.

            Source https://stackoverflow.com/questions/70128040

            QUESTION

            Add custom field only to error logs in logrus
            Asked 2022-Jan-07 at 07:58

            I'm using logrus for logging in golang. I use the following statements for logging.

            ...

            ANSWER

            Answered 2022-Jan-07 at 07:58

            Write custom Hook that will check if entry has severity field set and if not insert default value. Attach that hook to either default global or your own logger.

            You can limit hook to fire only on entries on logrus.ErrorLevel by including only that level in return value of Hook.Levels():

            Source https://stackoverflow.com/questions/70617528

            QUESTION

            How do I run my main.go file without having to run them separately outside of the containers?
            Asked 2022-Jan-03 at 20:53

            I have a main.go file that I use to run an app that starts a server that exposes a port where I can run endpoints from. I was trying to dockerise it and got as far as making working containers that hold the app and the db, but I still seem to have to run go run main.go after running docker-compose up -d.

            ...

            ANSWER

            Answered 2022-Jan-03 at 20:42

            Please, change the following line in the .env file:

            Source https://stackoverflow.com/questions/70569682

            QUESTION

            go build fails to find local dependencies on docker
            Asked 2021-Dec-02 at 22:41

            I'm trying to create a dockerfile for my go server but it keeps failing as it does not recognize some local dependencies (they are modules on the code itself, not external dependencies).

            example:

            ...

            ANSWER

            Answered 2021-Dec-02 at 22:41

            ADD ./src . - that copies the contents of src to the current folder, stripping away the src part.

            It should just be COPY . ./

            Also note that it's not recommended to have a src subfolder in your source tree - the folder that contains go.mod is already the source tree.

            Source https://stackoverflow.com/questions/70206905

            QUESTION

            Should logging of heavy JSON data with logrus be launched in a separate goroutine?
            Asked 2021-Nov-17 at 18:04

            I need to log relatively heavy JSON data within the web request handler. Does the logrus use blocking I/O? Should I call the logger.WithFields(fields).Info(heavy_message) in a separate goroutine?

            ...

            ANSWER

            Answered 2021-Nov-17 at 18:04

            QUESTION

            How to re-create log file automatically in logrus/lumberjack on macOS
            Asked 2021-Nov-02 at 06:06

            I use logrus and lumberjack for log file on macOS.

            ...

            ANSWER

            Answered 2021-Nov-01 at 11:20
            The "problem"

            Based on the stated behaviour, I assume this is happening on an OS which implements POSIX-compatible behaviour for files (so it's running on some kernel with Unix heritage — such as *BSD or Linux, — or it's a Mac OS system). On these systems, removing a file from a file system does nothing to that file's storage on that file system — as long as it is opened in at least a single running process.
            Specifically, to cite the POSIX documentation on open(2):

            If the link count of the file is 0, when all file descriptors associated with the file are closed, the space occupied by the file shall be freed and the file shall no longer be accessible.

            Having a file open is considered to increment its link count by 1, and removing a file from its filesystem is the same as decrementing that link count by 1.
            You might read more about link counts here.

            Supposedly the logging package you're using keep the log file opened, and so what happens is that you merely remove the file's name from the filesystem's directory it was it, but this does not in any way affect the logging process.
            Moreover, the process which has the file open is not notified when any of the file names goes away (on Unix-like systems a file might have many names at the same time—read about hard links).

            The solution

            Typically for Unix-like OSes is to have a way to explicitly ask the process to re-open its log file(s).
            Casually, a SIGUSR1 signal is used for this, so you could setup a handler (via signal.Notify) to setup a handler for such a signal and then make your log rotation code to kill -USR1 the running process to tell it re-open the log file, which will be recreated.

            Of course, more involved schemes could be implemented as you can use any form of IPC to communicate that command to your running process.

            Source https://stackoverflow.com/questions/69796031

            QUESTION

            viper dynamically loading config file has data race
            Asked 2021-Oct-31 at 16:20

            I would like to dynamically load config file and not restart my Go app. I wrote the below files, which runs but has data race.

            config.go

            ...

            ANSWER

            Answered 2021-Aug-25 at 04:20

            You lock viperLock called vipe.WatchConfig() and set vipe.OnConfigChange with a function it is also locking viperLock.

            Because you already called vipe.WatchConfig() and then it started to call vipe.OnConfigChange in separate go routine. it is also try to acquire the same lock. That's why there is a race condition.

            Call vipe.WatchConfig() after setting the vipe.OnConfigChange and after release the lock.

            It should be corrected as below.

            Source https://stackoverflow.com/questions/68915944

            QUESTION

            Go GRPC Refresh token for a bidirectional stream
            Asked 2021-Oct-20 at 18:15

            TLDR: I am looking for a way to update headers on an open stream for each call to stream.Send(msg) without closing the stream and opening a new one.

            Summary

            I have a GRPC client and server built to handle bidirectional streams. To authenticate with the server the client must send a JWT in the request headers, set as "authorization". The token is valid for 30 minutes. After the token has expired, the server will terminate the connection.

            I am looking for a way to refresh my authorization token from the client, and keep the stream open. The client should run in a loop executing a new request every 30 minutes with the updated token, and the updated payload. I have not seen a way to update a header from the client side for an already opened stream.

            Let's look at some code to get an idea of what the client side looks like. The code below has a function to create a new instance of the client, and another function to establish the connection to the GRPC server.

            ...

            ANSWER

            Answered 2021-Oct-20 at 18:15

            Headers are sent at the beginning of an RPC, and cannot be updated during the RPC. If you need to send data during the life of a stream, it needs to be part of the request message in your proto definition.

            Source https://stackoverflow.com/questions/69551307

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install logrus

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries

            Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link