Skip to content

Commit a9e160d

Browse files
committed
Merge pull request http-party#190 from egikander/log-messages-utc-option
Add option which enables UTC time format for log messages
2 parents 598316d + 98c0c21 commit a9e160d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ This will install `http-server` globally so that it may be run from the command
6464

6565
`-c` Set cache time (in seconds) for cache-control max-age header, e.g. -c10 for 10 seconds (defaults to '3600'). To disable caching, use -c-1.
6666

67+
`-U` or `--utc` Use UTC time format in log messages.
68+
6769
`-P` or `--proxy` Proxies all requests which can't be resolved locally to the given url. e.g.: -P http://someurl.com
6870

6971
`-S` or `--ssl` Enable https.

bin/http-server

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ if (argv.h || argv.help) {
2828
' -o [path] Open browser window after starting the server',
2929
' -c Cache time (max-age) in seconds [3600], e.g. -c10 for 10 seconds.',
3030
' To disable caching, use -c-1.',
31+
' -U --utc Use UTC time format in log messages.',
3132
'',
3233
' -P --proxy Fallback proxy if the request cannot be resolved. e.g.: http://someurl.com',
3334
'',
@@ -45,13 +46,14 @@ var port = argv.p || parseInt(process.env.PORT, 10),
4546
host = argv.a || '0.0.0.0',
4647
ssl = !!argv.S || !!argv.ssl,
4748
proxy = argv.P || argv.proxy,
49+
utc = argv.U || argv.utc,
4850
logger;
4951

5052
if (!argv.s && !argv.silent) {
5153
logger = {
5254
info: console.log,
5355
request: function (req, res, error) {
54-
var date = new Date().toUTCString();
56+
var date = utc ? new Date().toUTCString() : new Date();
5557
if (error) {
5658
logger.info(
5759
'[%s] "%s %s" Error (%s): "%s"',

0 commit comments

Comments
 (0)