winston-cloudwatch icon indicating copy to clipboard operation
winston-cloudwatch copied to clipboard

multi line log support?

Open barogo-jwyoon opened this issue 8 years ago • 3 comments

hi! i'm using winston-cloudwatch.

i try multi lline log transport.

ex.

[2017-04-26T04:36:44.876Z] POST 200 /api/v1/order/route HTTP/1.1 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36 [time 2132.164 ms] 
 "Request-Body" : {
	"point_coordinates": [
		{
			"lat": "37.52378691842046",
			"lon": "127.04685658762004"
		},
		{
			"lat": "37.4952615945518",
			"lon": "127.045626516174"
		},
		{
			"lat": "37.4641697457126",
			"lon": "127.102753896677"
		}
	]
}

but cloudWatch log.

info - ::ffff:127.0.0.1 - - [26/Apr/2017:02:28:58 +0000] "POST /api/v1/order/route HTTP/1.1" 200 6614 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"

why not add newline text?

thank you.

barogo-jwyoon avatar Apr 26 '17 06:04 barogo-jwyoon

This problem solved.

i'm using morgan npm.

before code

winston.stream = {
  write: (message, encoding) => {
    winston.info(message)
  }
}

app.use(morgan('combine', {
  'stream': logger.stream
}))

after code

winston.stream = {
  write: (message, encoding) => {
    winston.info(message)
  }
}

app.use(morgan('[:date[iso]] :method :status :url HTTP/:http-version :user-agent [time :response-time ms] :req-body', {
  'stream': logger.stream
}))

But logger.info(resp) and logger.info('resp', resp) different result in cloudWatch console.

logger.info(resp) - cloudWatch not logged

{ '0':
...
}

logger.info('resp', resp) - cloudWatch logged

resp: 
{ '0'
...
}

barogo-jwyoon avatar Apr 27 '17 01:04 barogo-jwyoon

I'm not sure what you're saying sorry, should I close the issue @barogo-jwyoon?

lazywithclass avatar Apr 27 '17 03:04 lazywithclass

my issue is not display at aws cloudWatch console with logger.info(resp).

but logger.info('resp', resp) display at aws cloudWatch.

resp = {
  '0': 'test'
  '1': 'test1'
}

barogo-jwyoon avatar Apr 27 '17 04:04 barogo-jwyoon