Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove logging framework #6124

Open
vwkd opened this issue Oct 17, 2024 · 11 comments
Open

Remove logging framework #6124

vwkd opened this issue Oct 17, 2024 · 11 comments

Comments

@vwkd
Copy link
Contributor

vwkd commented Oct 17, 2024

I'd suggest to remove the log module.

It isn't cross platform compatible, has the lowest JSR score of all @std packages with 88%, and is still unstable. The API has not evolved since originally porting it from Go, the API doesn't really fit JavaScript with magical global state that's influenced by the setup function, which the user must take care to always call first before any implementing library.

It's the only framework in the standard library. There are different ways to do a framework and not one best solution. There are various third-party frameworks, often better maintained and cross platform. Frameworks aren't a good fit for a standard library.

It's why a HTTP framework wasn't added multiple times #144 (comment) #1555 (comment). Related #1295.

@iuioiua
Copy link
Contributor

iuioiua commented Oct 19, 2024

I agree. I very much dislike @std/log. Discussions with Yoshiya (when I maintained this project) aligned with replacing the entire package with something better.

@halvardssm
Copy link
Contributor

I partially agree, I don’t mind the logger changing, but I am finding it very useful to have a standard logger library that can log to the console, a file and whatever pluggable custom logger I would find or make.

@BlackAsLight
Copy link
Contributor

I am in favour of it being changed instead of removed. I'm not 100% familiar with how it works, but things I'd like to see in a logging framework is:

  • The ability for libraries to implement it in their code that doesn't add additional computational strait if the main module isn't using it.
    • This could maybe be archived though accepting simple types in log.debug() or any type that implements a custom symbol like Symbol.Log, where calling the symbol on the object will have it handle how to stringify the object.
  • For the main module to decide completely how the output of the logger is displayed instead of opting for JSON.
  • A cron like expression that triggers to allow rotation of where the logs are going. For example if it's going to a file, lets one switch to a new file after x hours.
  • Many of the settings for the main module be configured via environment variables. This can remove people's disdain for the need to call log.setup() Like:
    • Default level being logged.
    • Library specific level being logged.
    • Location the logs are logged: "stdout", "stderr", a directory/file name, "null", or let runtime code decide.

@chyzwar
Copy link

chyzwar commented Oct 21, 2024

What is the best alternative? Last time I tried to use pino it was not working.
As user, I would want to know what is recommended logging framework in deno.

@kt3k
Copy link
Member

kt3k commented Oct 22, 2024

LogTape seems relatively popular to me https://github.com/dahlia/logtape
It officially supports Deno, and is available from JSR https://jsr.io/@logtape/logtape

@chyzwar
Copy link

chyzwar commented Oct 29, 2024

Logtape is not even a year old and only have one maintainer. It only has 510 stars. For me, this is the definition of niche and very early stage. Is there is a way see download stats in JSR?

@timreichen
Copy link
Contributor

The question I asked myself lately is if there is some middleground. I dislike the setup procedure and global state but find myself using a custom implementation of ConsoleLogger a lot, where one can set a debug loglevel based on dev or prod so the built in console can be avoided.
Maybe we could provide such building blocks and get rid of the other stuff so people can build log frameworks around them?

@iuioiua
Copy link
Contributor

iuioiua commented Oct 31, 2024

Logtape is not even a year old and only have one maintainer. It only has 510 stars. For me, this is the definition of niche and very early stage. Is there is a way see download stats in JSR?

I think if the quality of the design is good enough, the package is good enough to be adopted anyway.

@chyzwar
Copy link

chyzwar commented Nov 1, 2024

I think if the quality of the design is good enough, the package is good enough to be adopted anyway.

I disagree. The maintainer could disappear tomorrow, and you will end up with hundreds of call sites to a library that is no longer maintained. Logtape support both structured logging and lazy evaluation these features are in my opinion are bad ideas and need to be carefully evaluated if you do not want to have another Log4Shell moment.

For me the biggest benefit of Deno is DX. When you use Deno you no longer need to pick random quality libraries. You have a great standard library that can cover common use cases. Things like logger are fundamental to developing of any application. I suspect that logger is one of the more used packages from std.

@kt3k
Copy link
Member

kt3k commented Nov 1, 2024

Last time I tried to use pino it was not working.

pino now seems working to me in Deno (The below worked):

import pino from "npm:pino";
const logger = pino();
logger.info("hello world");
const child = logger.child({ a: "property" });
child.info("hello child!");

pino seems great in its support policy https://github.com/pinojs/pino/blob/main/docs/lts.md

@chyzwar
Copy link

chyzwar commented Nov 4, 2024

pino now seems working to me in Deno (The below worked):

Not on Windows: pinojs/pino#2060 Deno is not officially supported by pino it works only because improved node.js compact (can break any moment)

In my opinion, there is no production ready logger for Deno.

As stand today there is no production

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants