Actually, when browsing the sources for google-cloud-node I discovered
there is now a new winston transport being developed -
*@google-cloud/logging-winston
<https://github.com/GoogleCloudPlatform/google-cloud-node/tree/master/packages/logging-winston>*.
Usage is greatly simplified:
var winston = require('winston');var transport =
require('@google-cloud/logging-winston');
winston.add(transport);
winston.error('warp nacelles offline');winston.verbose('sheilds at 99%');
On Wednesday, April 5, 2017 at 3:32:00 AM UTC-4, Marco Galassi wrote:
>
> Hi Adam,
> thank you for your answer.
> I am probably just dumb, but I can't make the Cloud Logging APIs work.
> I have installed @google-cloud/logging through
>
> *npm install --save @google-cloud/logging*
>
> as pointed out in the documentation, put a random
>
> *logging.log('this is a log')*
>
> in the / root handler, before sending back a response to the client, and
> still, when I access the page,
> I only get an internal server error. The corresponding log in Stackdriver
> is simply: "TypeError: logging.log is not a function at app.get"
> My code currently looks as simple as this:
> const express = require('express');
> var logging = require('@google-cloud/logging');
> const app = express();
>
> app.get('/', (req, res) => {
> logging.log('this is a super cool log'); // Shouldn't this log?
> res.status(200).send('Hello, world!');
> });
>
> if (module === require.main) {
> const server = app.listen(process.env.PORT || 8080, () => {
> const port = server.address().port;
> console.log(`App listening on port ${port}`);
> })
> }
> module.exports = app;
>
>
> I can't understand very well how to use it nor I can find a complete
> example.
>
> Any help would be really appreciated.
>
>
>
> On Tuesday, April 4, 2017 at 9:56:55 PM UTC+2, Adam (Cloud Platform
> Support) wrote:
>>
>> I see you'd already opened an issue
>> <https://issuetracker.google.com/36851656> but it was closed. The reason
>> being is that Google does not maintain the winston-gae project, which is an
>> open source project. We do provide access to the Cloud Logging APIs via
>> google-cloud-node
>> <https://googlecloudplatform.github.io/google-cloud-node/#/docs/logging/0.9.0/logging/log>
>>
>> though which you can use to implement your own logger or use directly in
>> your code (or which can be referenced to update winston-gae, or implement a
>> different solution).
>>
>> On Monday, April 3, 2017 at 3:00:19 AM UTC-4, Marco Galassi wrote:
>>>
>>> Yes, but that basically is just the same as doing
>>> console.log('stdout');
>>> console.error('stderr');
>>>
>>> It would be nice to open an issue to ask google to implement it. Where
>>> could I do this?
>>>
>>> Marco
>>>
>>>
>>> On Saturday, April 1, 2017 at 12:25:40 AM UTC+2, Adam (Cloud Platform
>>> Support) wrote:
>>>>
>>>> I've also been unable to get winston-gae working. It hasn't been
>>>> updated in over 2 years and is not an official Google library, so for now
>>>> it seems it's in need of a maintainer.
>>>>
>>>> The standard winston <https://www.npmjs.com/package/winston> logger
>>>> does work, but only outputs to stdout and as such you don't get proper
>>>> severity in the Logs Viewer.
>>>>
>>>> On Friday, March 31, 2017 at 11:03:20 AM UTC-4, Marco Galassi wrote:
>>>>>
>>>>>
>>>>> I am using nodejs on App Engine and I would like to have the ability
>>>>> to log my application in an easy manner.
>>>>> Possibily, I would like to be able to log as easy as in python
>>>>> standard environment
>>>>> <https://cloud.google.com/appengine/docs/standard/python/logs/>:
>>>>>
>>>>> import logging
>>>>>> import webapp2
>>>>>> class MainPage(webapp2.RequestHandler):
>>>>>> def get(self):
>>>>>> logging.debug('This is a debug message')
>>>>>> logging.info('This is an info message')
>>>>>> logging.warning('This is a warning message')
>>>>>> logging.error('This is an error message')
>>>>>> logging.critical('This is a critical message')
>>>>>> try:
>>>>>> raise ValueError('This is a sample value error.')
>>>>>> except ValueError:
>>>>>> logging.exception('A example exception log.')
>>>>>> self.response.out.write('Logging example.')
>>>>>
>>>>>
>>>>>
>>>>> app = webapp2.WSGIApplication([
>>>>>
>>>>> ('/', MainPage)
>>>>>> ], debug=True)
>>>>>
>>>>>
>>>>> This is very useful since it shows the logs with the corresponding
>>>>> logging severity in the Stackdriver Logging console.
>>>>> Unfortunately, it doesn't look that something like this is possible on
>>>>> NodeJS.
>>>>>
>>>>> I have tried to follow what the documentation says
>>>>> <https://cloud.google.com/appengine/docs/flexible/nodejs/writing-application-logs>
>>>>>
>>>>> on logging on NodeJS, which says that I can use winston-gae
>>>>> <https://www.npmjs.com/package/winston-gae>, but it doesn't work at
>>>>> all.
>>>>>
>>>>> Any help is very appreciated.
>>>>>
>>>>
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-appengine/3119cf46-7009-46ba-8778-283b3c80a264%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.