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.

Logger implementation

See original GitHub issue

I’m opening this issue to start discussion on vision for logging module.

Coming from Python world and being familiar with its library, my intent for Deno logging was to emulate Python’s approach.

Its mechanism is based on:

  • loggers - object to call to log something obviously
  • LogRecord - contains timestamps and metadata about message logged by logger
  • handlers - also known as transports. One logger may utilize multiple `handlers. Eg. console handler that print output to console, file handler that streams logs to file on disk.
  • filters - predicates that interact with LogRecords, allowing for very granular control. Both loggers and handlers can have filters
  • formatters - a function that given LogRecord instance returns output string

Loggers are accessed using getLogger function, so wherever in code you do const logger = logging.getLogger('myLogger'); you get the same instance.

This page gives a nice overview how to use it in action.

One of more popular node’s logging libraries winston takes not so different approach.

I’m really interested what community expects.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:19 (19 by maintainers)

github_iconTop GitHub Comments

2reactions
rycommented, Jan 3, 2019

My initial idea was to leverage Error.stack but I’m concerned with performance, throwing error at each logged message can’t be a good idea.

Hm… It’s possible we could provide __LINE__ as a preprocessed symbol in deno. For the filename we could use import.meta once https://github.com/denoland/deno/issues/975 lands.

1reaction
bartlomiejucommented, Feb 4, 2019

I reckon log implementation is good enough now we can close this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Logger in Java | Java Logging Basics with Log4j and util
Loggers in Java are objects which trigger log events, They are created and are called in the code of the application, where they...
Read more >
Logger in Java - Java Logging Example - DigitalOcean
java.util.logging.LogManager is the class that reads the logging configuration, create and maintains the logger instances. We can use this class ...
Read more >
Logging in Java - GeeksforGeeks
The logger class provides methods for logging. Since LogManager is the one doing actual logging, its instances are accessed using the ...
Read more >
Java Logger - Javatpoint
In Java, Logging is an API that provides the ability to trace out the errors of the applications. When an application generates the...
Read more >
How to Implement Logger in Python | Analytics Vidhya - Medium
I have created logger for my program which will take input-loglevel from properties file. I will mention the log-level in the properties file....
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