-
Notifications
You must be signed in to change notification settings - Fork 596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add winston logging transport #1830
Conversation
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
46b858d
to
b51faa7
Compare
CLAs look good, thanks! |
var metadata = this.metadata_; | ||
if (meta) { | ||
// Logging proto requires that the label values be strings, so we convert | ||
// using util.inspect. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
@ofrobots I've added a commit. The main differences are,
Can you take a quick look and make sure it still behaves as intended? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Added comments.
packages/logging-winston/README.md
Outdated
}); | ||
|
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
packages/logging-winston/README.md
Outdated
|
||
### Elsewhere | ||
|
||
If you are not running this client on Google Compute Engine, you need a Google Developers service account. To create a service account: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
*/ | ||
function LoggingWinston(options) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
* either succeeds or gives up writing the log entry to the remote server. | ||
* @param {object=} metadata - Winston-provided metadata that should be attached | ||
* to the log entry. Each property will be converted to a string using | ||
* `JSON.stringify`. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
if (_.isFunction(meta) && !callback) { | ||
callback = meta; | ||
meta = null; | ||
LoggingWinston.prototype.log = function(levelName, msg, metadata, callback) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
var metadata = this.metadata_; | ||
if (meta) { | ||
if (metadata) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
6faa1ab
to
568fec4
Compare
packages/logging-winston/README.md
Outdated
|
||
If you are running your application in a different environment, for example, locally, on-premise, or on another cloud provider, you may need to provide some configuration. | ||
If you are running this client on Google Compute Engine, we handle authentication for you with no configuration. You just need to make sure that when you [set up the GCE instance][gce-how-to], you add the correct scopes for the APIs you want to access. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
I'll finish up the unit tests for this. Are we including this in the google-cloud bundle, e.g.: var gcloud = require('google-cloud')();
var transport = gcloud.loggingWinston; Also, is there a better name than var stackdriverTransport = require('@google-cloud/logging-winston') |
/cc @JustinBeckwith @omaray for more opinions on the name. This library isn't a client library but rather an integration library. I think the general rule of var names coinciding doesn't have to apply here. Module names are primarily for discoverability of purpose, so I still prefer Perhaps we should change the examples to the following to make things more elegant: var transport = require('@google-cloud/logging-winston'); I don't have very strong opinions on bundling this with |
I've improved the examples. |
a8bdbb4
to
a3ee52a
Compare
@stephenplusplus I've add some more unit tests. PTAL. |
I made some alterations from your last commit with regards to the input validation and testing strategy, keeping it more in line with the conventions here-- letting validation happen "last-minute", by an upstream module or API request, meaning we try to only throw if the next line of code in our script wouldn't work if they gave us something invalid. And with the tests, we stub everything to make sure the tests are as isolated as possible from logic that exists anywhere else. PTAL! |
Sorry for the delay. LGTM. |
When should we expect this to land? |
57c5c5e
to
039e1b1
Compare
Thanks for landing. Can we publish a package for this too? |
Published as |
npm run docs
parser doesn't like my docs yet (is there any info/docs on what the custom parser requires?)This PR adds a new module
@google-cloud/logging-winston
that provides simple, minimal config way of logging to Stackdriver Logging from applications using winston.The code is fairly small, but it should be a standalone module because we need to depend upon winston (the transport must be an instance of
winston.Transport
). Adding this dependency to@google-cloud/logging
doesn't make sense (we should not install winston for people who are not asking for winston support)./cc @cristiancavalli