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.

Add different and extendable logging transports

See original GitHub issue

It would be nice if Logdown could write to log files.

The atma-logger for example is able to write to the filesystem or to a remote server (via HTTP): https://github.com/atmajs/atma-logger#transports

There is also winston, a multi-transport async logging library. With winston logging transports can be changed the following way:

winston = require('winston');

winston.add(winston.transports.File, {
  filename: config.logging_file,
  handleExceptions: true,
})
.remove(winston.transports.Console)
.info('Name', 'Message');

Would be great to have something similar with Logdown. 😃

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:29 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
caiogondimcommented, Dec 23, 2016

I like the idea a lot.

I would make as simple as possible, using an array that is a collection of functions that will be called on every logdown method.

logdown.transports = []

My proposal for the API:

  • Adding transport
logdown.transports = logdown.transports.concat([
  (msg) => {
    console.log(msg)
  },
  (msg) => {
    fs.writeFile(filePath, msg)
  }
])
  • Removing transport
logdown.transports.splice(1, 1)
  • List transports
logdown.transports // => Array of functions

Don’t think we should provide any custom transport function, since they are super easy to implement.

1reaction
caiogondimcommented, Oct 10, 2017

BTW. Would it better to add Babel? And what browsers do we support?

The reasoning for not adding babel is the same for TypeScript: bundle size This is a small lib, don’t think we would benefit a lot using Babel.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Winston Logging - separate levels to separate Transports
You can create a custom transport and log only the levels you want. Here is an example just to give you an idea:...
Read more >
Node Logging Basics - The Ultimate Guide To Logging - Loggly
Use multiple transports of the same type; Add custom transports; Stream logs; Query logs; Profiling; Handle uncaught exceptions; Use one of a range...
Read more >
electron-log/extend.md at master - GitHub
It returns a message data property with some transformations applied. Example of adding a custom transform function. log.transports.file.
Read more >
tslog - Extensible TypeScript Logger for Node.js and Browser ...
Every incoming log message runs through a number of steps before being displayed or handed over to a "transport". Every step can be...
Read more >
winston - npm
A transport is essentially a storage device for your logs. Each instance of a winston logger can have multiple transports configured at ...
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