question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request - Built-in universal logger

See original GitHub issue

Feature request

Is your feature request related to a problem? Please describe.

Universal logging that is light and customisable isn’t an easy task.

I’m currently using @unly/utils-simple-logger, which relies on winston (~ 40kB).

There are a few limitations with this implementation:

  • It’s huge, in comparison to the benefits it provides (it could be a <2kB lib)
  • It doesn’t play well with stack traces, because it wraps console and “lies” about where calls are from
  • It doesn’t respect the console.log API, and cannot be a drop-in replacement for console.log

It has come to my attention through an open issue that Winston was adding about ~60kB to all pages (404 > 344kB without it), and this is a huge difference.

I’m using a custom logger for the following reasons:

  • There are logs I want to be stripped in production stage, because I don’t want them visible (neither in server side nor client side), sometimes it’s to avoid spam/noise, sometimes it’s to avoid leaking sensitive debug info

Describe the solution you’d like

I believe this could be made available as an external package for those who wish to use it.

What do you use for logging at Next?

Describe alternatives you’ve considered

I’ve spent a few hours looking around what alternatives I could use, but after studying about half a dozen of alternatives, I’ve come short to no viable solution. Either they aren’t universal, or too big, or lack features, aren’t maintained, etc.

The 2 most interesting alternatives I’ve found are:

Overall, ulog looks great, but there are a few important issues and bad design decisions. (https://github.com/Download/ulog/issues/16)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
Downloadcommented, Jun 23, 2020

Hi guys, I’m the author of ulog.

I wrote ulog an eon ago to be tiny and powerful and work everywhere. And 1.x is pretty much succeeding at that. However I found that I had 2 problems with it:

  • Even though I made ulog as small as I could get it, I still did not want to use it in libraries / frameworks as a dependency because I don’t want to tie consumers to my choice of logging library
  • I wanted more features such as formatting, which made the previous point even worse. I certainly don’t want to tie consumers of a library I am making to my choice of big logging library

I came up with this solution:

anylogger

The logger for libraries

When we want to do logging from a library, we don’t want to force the choice of logging framework on the application developer. Instead, we want to use whatever logging framework the application developer selected. anylogger let’s you do just that.

The idea here is a logging facade. It’s like slf4j in the Java world. A facade with a generic interface that you back with the logging library of your choice.

Currently I am working to get the following working:

It’s work in progress… I’m doing it on my own atm… And I don’t always have time to work on it.

However I really do feel a logging facade is what the Javascript world needs so framework and library vendors can just support any logger easily.

0reactions
Manikanta-20commented, Jun 3, 2020

or any logger management ui like graylog?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Feature request - Built-in universal logger #23933 - GitHub
Universal logging that is light and customisable isn't an easy task. I'm currently using @unly/utils-simple-logger , which relies on winston (~ 40kB) ...
Read more >
Logging in .NET Core and ASP.NET Core | Microsoft Learn
Built-in logging providers; Third-party logging providers. Create logs. To create logs, use an ILogger<TCategoryName> object from dependency ...
Read more >
How to Collect, Customize, and Centralize Node.js Logs
Learn some best practices for collecting and customizing logs from your Node.js applications.
Read more >
Q100067: Logging Feature Requests - Foundry Support
SUMMARY Users of our products often have great ideas for features they would like to see added. A feature enhancement is a request...
Read more >
Logging in Swift | steipete's blog
With iOS 14, Apple improved the built-in logging framework and added ... First off, the new string interpolation feature of Swift 5 is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found