Socket
Socket
Sign inDemoInstall

@google-cloud/logging-bunyan

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@google-cloud/logging-bunyan - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

5

package.json
{
"name": "@google-cloud/logging-bunyan",
"version": "0.1.0",
"version": "0.2.0",
"author": "Google Inc.",

@@ -31,3 +31,4 @@ "description": "Stackdriver Logging stream for Bunyan",

"dependencies": {
"@google-cloud/logging": "^0.7.0"
"@google-cloud/logging": "^0.8.1",
"extend": "^3.0.0"
},

@@ -34,0 +35,0 @@ "devDependencies": {

60

src/index.js

@@ -23,3 +23,6 @@ /*!

var extend = require('extend');
var logging = require('@google-cloud/logging');
var util = require('util');
var Writable = require('stream').Writable;

@@ -95,4 +98,11 @@ /**

this.log_ = logging(options).log(this.logName_);
this.log_ = logging(options).log(this.logName_, {
removeCircular: true
});
Writable.call(this, {
objectMode: true
});
}
util.inherits(LoggingBunyan, Writable);

@@ -123,3 +133,3 @@ /**

/**
* Relay a log entry to the logging agent. This is normally called by bunyan.
* Format a bunyan record into a Stackdriver log entry.
*

@@ -130,3 +140,3 @@ * @param {object} record - Bunyan log record.

*/
LoggingBunyan.prototype.write = function(record) {
LoggingBunyan.prototype.formatEntry_ = function(record) {
if (typeof record === 'string') {

@@ -138,4 +148,26 @@ throw new Error(

var level = BUNYAN_TO_STACKDRIVER[record.level];
// Stackdriver Log Viewer picks up the summary line from the 'message' field
// of the payload. Unless the user has provided a 'message' property also,
// move the 'msg' to 'message'.
if (!record.message) {
// Clone the object before modifying it.
record = extend({}, record);
// If this is an error, report the full stack trace. This allows Stackdriver
// Error Reporting to pick up errors automatically (for severity 'error' or
// higher). In this case we leave the 'msg' property intact.
// https://cloud.google.com/error-reporting/docs/formatting-error-messages
//
// TODO(ofrobots): when resource.type is 'global' we need to additionally
// provide serviceContext.service as part of the entry for Error Reporting
// to automatically pick up the error.
if (record.err && record.err.stack) {
record.message = record.err.stack;
} else if (record.msg) {
// Simply rename `msg` to `message`.
record.message = record.msg;
delete record.msg;
}
}
var entryMetadata = {

@@ -146,10 +178,22 @@ resource: this.resource_,

var entry = this.log_.entry(entryMetadata, record);
return this.log_.entry(entryMetadata, record);
};
this.log_[level](entry, function() {
// no-op to avoid a promise being returned.
});
/**
* Relay a log entry to the logging agent. This is called by bunyan through
* Writable#write.
*
* @param {object} record - Bunyan log record.
*
* @private
*/
LoggingBunyan.prototype._write = function(record, encoding, callback) {
var entry = this.formatEntry_(record);
var level = BUNYAN_TO_STACKDRIVER[record.level];
this.log_[level](entry, callback);
};
// TODO(ofrobots): implement _writev as well.
module.exports = LoggingBunyan;
module.exports.BUNYAN_TO_STACKDRIVER = BUNYAN_TO_STACKDRIVER;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc