Skip to content

Document other shell variable for debuging express#1048

Merged
dougwilson merged 1 commit into
expressjs:gh-pagesfrom
zombieleet:patch-1
Apr 1, 2020
Merged

Document other shell variable for debuging express#1048
dougwilson merged 1 commit into
expressjs:gh-pagesfrom
zombieleet:patch-1

Conversation

@zombieleet

Copy link
Copy Markdown
Contributor

Specified DEBUG_FD and DEBUG_COLORS shell variables to handle redirection of logs to a file and enabling/disabling color output respectively

@wesleytodd

Copy link
Copy Markdown
Member

Hi @zombieleet, thanks for the addition! Can you talk about why it requires re-asigning the FD to put debug out into a file? This will redirect only debug output, but wont most people be alright with just normal piping to file $ DEBUG=express:* node index.js > log.txt? Just thinking about keeping the docs simple :)

@zombieleet

Copy link
Copy Markdown
Contributor Author

@wesleytodd $ DEBUG=express:* node index.js > log.txt does not send the DEBUG output to log.txt

@wesleytodd

wesleytodd commented Jun 7, 2019

Copy link
Copy Markdown
Member

Oh, the debug module outputs on stderr? Sorry I am just not a user of that module so am not familiar with the way it works. Even so, you don't need to change the fd I think. I tried doing:

$ cat index.js
'use strict'
const debug = require('debug')('foo')
debug('testing')

$ DEBUG=foo node index.js 2> log.txt

$ cat log.txt
2019-06-07T16:09:52.972Z foo testing

Seems to work with the normal stderr fd, right?

@zombieleet

Copy link
Copy Markdown
Contributor Author

Yes, that is right. But I see no reason why the default stream should be stderr. But the default stream can be changed to stdout output streams . I think this should be in the docs, most express.js users might be interested in sending the logs to a file rather than the terminal

@wesleytodd

Copy link
Copy Markdown
Member

I see no reason why the default stream should be stderr

I think this is a common best practice for *nix systems, a program's debug output being on stderr. While I understand your viewpoint, I see no reason we should recommend something different from the norm.

I think this should be in the docs, most express.js users might be interested in sending the logs to a file rather than the terminal

This I completely agree with. And I would like to merge this, but I think adding the more complex example might make it harder for beginners to know what is going on. That is why I was hoping to simplify the example to just DEBUG=foo node index.js 2> log.txt.

@dougwilson dougwilson closed this in 776855b Apr 1, 2020
@dougwilson dougwilson merged commit 776855b into expressjs:gh-pages Apr 1, 2020
@github-pages github-pages Bot temporarily deployed to github-pages April 1, 2020 03:06 Inactive
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

Successfully merging this pull request may close these issues.

3 participants