Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@google-cloud/logging-min

Package Overview
Dependencies
Maintainers
4
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 10.1.0 to 10.1.1

5

build/src/index.d.ts

@@ -28,3 +28,3 @@ /*!

import { Log, GetEntriesRequest, TailEntriesRequest, LogOptions } from './log';
import { LogSync } from './log-sync';
import { LogSync, LogSyncOptions } from './log-sync';
import { Sink } from './sink';

@@ -693,2 +693,3 @@ import { Duplex, Writable } from 'stream';

* @param {object} transport An optional write stream.
* @param {LogSyncOptions} options An optional configuration object.
* @returns {LogSync}

@@ -709,3 +710,3 @@ *

*/
logSync(name: string, transport?: Writable): LogSync;
logSync(name: string, transport?: Writable, options?: LogSyncOptions): LogSync;
/**

@@ -712,0 +713,0 @@ * Get a reference to a Cloud Logging sink.

2

build/src/index.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.v2=exports.protos=exports.Logging=exports.Sink=exports.LogSync=exports.formatLogName=exports.assignSeverityToEntries=exports.Severity=exports.Log=exports.Entry=exports.detectServiceContext=exports.middleware=void 0;const common_1=require("@google-cloud/common");const paginator_1=require("@google-cloud/paginator");const projectify_1=require("@google-cloud/projectify");const promisify_1=require("@google-cloud/promisify");const arrify=require("arrify");const extend=require("extend");const gax=require("google-gax");const pumpify=require("pumpify");const streamEvents=require("stream-events");const middleware=require("./middleware");exports.middleware=middleware;const metadata_1=require("./utils/metadata");Object.defineProperty(exports,"detectServiceContext",{enumerable:true,get:function(){return metadata_1.detectServiceContext}});const version=require("../../package.json").version;const v2=require("./v2");exports.v2=v2;const entry_1=require("./entry");Object.defineProperty(exports,"Entry",{enumerable:true,get:function(){return entry_1.Entry}});const log_common_1=require("./utils/log-common");Object.defineProperty(exports,"Severity",{enumerable:true,get:function(){return log_common_1.Severity}});Object.defineProperty(exports,"formatLogName",{enumerable:true,get:function(){return log_common_1.formatLogName}});Object.defineProperty(exports,"assignSeverityToEntries",{enumerable:true,get:function(){return log_common_1.assignSeverityToEntries}});const log_1=require("./log");Object.defineProperty(exports,"Log",{enumerable:true,get:function(){return log_1.Log}});const log_sync_1=require("./log-sync");Object.defineProperty(exports,"LogSync",{enumerable:true,get:function(){return log_sync_1.LogSync}});const sink_1=require("./sink");Object.defineProperty(exports,"Sink",{enumerable:true,get:function(){return sink_1.Sink}});const stream_1=require("stream");class Logging{constructor(options){const scopes=[];const clientClasses=[v2.ConfigServiceV2Client,v2.LoggingServiceV2Client,v2.MetricsServiceV2Client];for(const clientClass of clientClasses){for(const scope of clientClass.scopes){if(scopes.indexOf(scope)===-1){scopes.push(scope)}}}const options_=extend({libName:"gccl",libVersion:version,scopes:scopes},options);this.api={};this.auth=new gax.GoogleAuth(options_);this.options=options_;this.projectId=this.options.projectId||"{{projectId}}";this.configService=new v2.ConfigServiceV2Client(this.options);this.loggingService=new v2.LoggingServiceV2Client(this.options)}async createSink(name,config){if(typeof name!=="string"){throw new Error("A sink name must be provided.")}if(typeof config!=="object"){throw new Error("A sink configuration object must be provided.")}if(common_1.util.isCustomType(config.destination,"bigquery/dataset")){await this.setAclForDataset_(config)}if(common_1.util.isCustomType(config.destination,"pubsub/topic")){await this.setAclForTopic_(config)}if(common_1.util.isCustomType(config.destination,"storage/bucket")){await this.setAclForBucket_(config)}const reqOpts={parent:"projects/"+this.projectId,sink:extend({},config,{name:name}),uniqueWriterIdentity:config.uniqueWriterIdentity};delete reqOpts.sink.gaxOptions;delete reqOpts.sink.uniqueWriterIdentity;await this.setProjectId(reqOpts);const[resp]=await this.configService.createSink(reqOpts,config.gaxOptions);const sink=this.sink(resp.name);sink.metadata=resp;return[sink,resp]}entry(resource,data){return new entry_1.Entry(resource,data)}async getEntries(opts){const options=opts?opts:{};let reqOpts=extend({orderBy:"timestamp desc"},options);const time=new Date;time.setDate(time.getDate()-1);const timeFilter=`timestamp >= "${time.toISOString()}"`;if(!options.filter){reqOpts=extend({filter:timeFilter},reqOpts)}else if(!options.filter.includes("timestamp")){reqOpts.filter+=` AND ${timeFilter}`}reqOpts.resourceNames=arrify(reqOpts.resourceNames);this.projectId=await this.auth.getProjectId();const resourceName="projects/"+this.projectId;if(reqOpts.resourceNames.indexOf(resourceName)===-1){reqOpts.resourceNames.push(resourceName)}delete reqOpts.autoPaginate;delete reqOpts.gaxOptions;const gaxOptions=extend({autoPaginate:options.autoPaginate},options.gaxOptions);const resp=await this.loggingService.listLogEntries(reqOpts,gaxOptions);const[entries]=resp;if(entries){resp[0]=entries.map(entry_1.Entry.fromApiResponse_)}return resp}getEntriesStream(options={}){let requestStream;const userStream=streamEvents(pumpify.obj());userStream.abort=()=>{if(requestStream){requestStream.abort()}};const toEntryStream=new stream_1.Transform({objectMode:true,transform:(chunk,encoding,callback)=>{callback(null,entry_1.Entry.fromApiResponse_(chunk))}});userStream.once("reading",()=>{this.auth.getProjectId().then(projectId=>{this.projectId=projectId;if(options.log){if(options.filter){options.filter=`(${options.filter}) AND logName="${(0,log_common_1.formatLogName)(this.projectId,options.log)}"`}else{options.filter=`logName="${(0,log_common_1.formatLogName)(this.projectId,options.log)}"`}delete options.log}const reqOpts=extend({orderBy:"timestamp desc"},options);reqOpts.resourceNames=arrify(reqOpts.resourceNames);reqOpts.resourceNames.push(`projects/${this.projectId}`);delete reqOpts.autoPaginate;delete reqOpts.gaxOptions;const gaxOptions=extend({autoPaginate:options.autoPaginate},options.gaxOptions);let gaxStream;requestStream=streamEvents(new stream_1.PassThrough({objectMode:true}));requestStream.abort=()=>{if(gaxStream&&gaxStream.cancel){gaxStream.cancel()}};if(!global.GCLOUD_SANDBOX_ENV){requestStream.once("reading",()=>{try{gaxStream=this.loggingService.listLogEntriesStream(reqOpts,gaxOptions)}catch(error){requestStream.destroy(error);return}gaxStream.on("error",err=>{requestStream.destroy(err)}).pipe(requestStream);return})}userStream.setPipeline(requestStream,toEntryStream)})});return userStream}tailEntries(options={}){const userStream=streamEvents(pumpify.obj());let gaxStream;userStream.abort=()=>{if(gaxStream&&gaxStream.cancel){gaxStream.cancel()}};const transformStream=new stream_1.Transform({objectMode:true,transform:(chunk,encoding,callback)=>{callback(null,(()=>{const formattedEntries=[];chunk.entries.forEach(entry=>{formattedEntries.push(entry_1.Entry.fromApiResponse_(entry))});const resp={entries:formattedEntries,suppressionInfo:chunk.suppressionInfo};return resp})())}});this.auth.getProjectId().then(projectId=>{this.projectId=projectId;if(options.log){if(options.filter){options.filter=`(${options.filter}) AND logName="${(0,log_common_1.formatLogName)(this.projectId,options.log)}"`}else{options.filter=`logName="${(0,log_common_1.formatLogName)(this.projectId,options.log)}"`}}options.resourceNames=arrify(options.resourceNames);options.resourceNames.push(`projects/${this.projectId}`);const writeOptions={resourceNames:options.resourceNames,...options.filter&&{filter:options.filter},...options.bufferWindow&&{bufferwindow:options.bufferWindow}};if(!global.GCLOUD_SANDBOX_ENV){gaxStream=this.loggingService.tailLogEntries(options.gaxOptions);gaxStream.write(writeOptions);userStream.setPipeline(gaxStream,transformStream)}});return userStream}async getLogs(opts){const options=opts?opts:{};this.projectId=await this.auth.getProjectId();const reqOpts=extend({},options,{parent:"projects/"+this.projectId});delete reqOpts.autoPaginate;delete reqOpts.gaxOptions;const gaxOptions=extend({autoPaginate:options.autoPaginate},options.gaxOptions);const resp=await this.loggingService.listLogs(reqOpts,gaxOptions);const[logs]=resp;if(logs){resp[0]=logs.map(logName=>this.log(logName))}return resp}getLogsStream(options={}){options=options||{};let requestStream;const userStream=streamEvents(pumpify.obj());userStream.abort=()=>{if(requestStream){requestStream.abort()}};const toLogStream=new stream_1.Transform({objectMode:true,transform:(chunk,encoding,callback)=>{callback(null,this.log(chunk))}});userStream.once("reading",()=>{this.auth.getProjectId().then(projectId=>{this.projectId=projectId;const reqOpts=extend({},options,{parent:"projects/"+this.projectId});delete reqOpts.gaxOptions;const gaxOptions=extend({autoPaginate:options.autoPaginate},options.gaxOptions);let gaxStream;requestStream=streamEvents(new stream_1.PassThrough({objectMode:true}));requestStream.abort=()=>{if(gaxStream&&gaxStream.cancel){gaxStream.cancel()}};requestStream.once("reading",()=>{try{gaxStream=this.loggingService.listLogsStream(reqOpts,gaxOptions)}catch(error){requestStream.destroy(error);return}gaxStream.on("error",err=>{requestStream.destroy(err)}).pipe(requestStream);return});userStream.setPipeline(requestStream,toLogStream)})});return userStream}async getSinks(opts){const options=opts?opts:{};this.projectId=await this.auth.getProjectId();const reqOpts=extend({},options,{parent:"projects/"+this.projectId});delete reqOpts.autoPaginate;delete reqOpts.gaxOptions;const gaxOptions=extend({autoPaginate:options.autoPaginate},options.gaxOptions);const resp=await this.configService.listSinks(reqOpts,gaxOptions);const[sinks]=resp;if(sinks){resp[0]=sinks.map(sink=>{const sinkInstance=this.sink(sink.name);sinkInstance.metadata=sink;return sinkInstance})}return resp}getSinksStream(options){const self=this;options=options||{};let requestStream;const userStream=streamEvents(pumpify.obj());userStream.abort=()=>{if(requestStream){requestStream.abort()}};const toSinkStream=new stream_1.Transform({objectMode:true,transform:(chunk,encoding,callback)=>{const sinkInstance=self.sink(chunk.name);sinkInstance.metadata=chunk;callback(null,sinkInstance)}});userStream.once("reading",()=>{this.auth.getProjectId().then(projectId=>{this.projectId=projectId;const reqOpts=extend({},options,{parent:"projects/"+self.projectId});delete reqOpts.gaxOptions;const gaxOptions=extend({autoPaginate:options.autoPaginate},options.gaxOptions);let gaxStream;requestStream=streamEvents(new stream_1.PassThrough({objectMode:true}));requestStream.abort=()=>{if(gaxStream&&gaxStream.cancel){gaxStream.cancel()}};if(!global.GCLOUD_SANDBOX_ENV){requestStream.once("reading",()=>{try{gaxStream=this.configService.listSinksStream(reqOpts,gaxOptions)}catch(error){requestStream.destroy(error);return}gaxStream.on("error",err=>{requestStream.destroy(err)}).pipe(requestStream);return})}userStream.setPipeline(requestStream,toSinkStream)})});return userStream}log(name,options){return new log_1.Log(this,name,options)}logSync(name,transport){return new log_sync_1.LogSync(this,name,transport)}sink(name){return new sink_1.Sink(this,name)}request(config,callback){const self=this;const isStreamMode=!callback;let gaxStream;let stream;if(isStreamMode){stream=streamEvents(new stream_1.PassThrough({objectMode:true}));stream.abort=()=>{if(gaxStream&&gaxStream.cancel){gaxStream.cancel()}};stream.once("reading",makeRequestStream)}else{makeRequestCallback()}function prepareGaxRequest(callback){self.auth.getProjectId((err,projectId)=>{if(err){callback(err);return}self.projectId=projectId;let gaxClient=self.api[config.client];if(!gaxClient){gaxClient=new v2[config.client](self.options);self.api[config.client]=gaxClient}let reqOpts=extend(true,{},config.reqOpts);reqOpts=(0,projectify_1.replaceProjectIdToken)(reqOpts,projectId);const requestFn=gaxClient[config.method].bind(gaxClient,reqOpts,config.gaxOpts);callback(null,requestFn)})}function makeRequestCallback(){if(global.GCLOUD_SANDBOX_ENV){return}prepareGaxRequest((err,requestFn)=>{if(err){callback(err);return}requestFn(callback)})}function makeRequestStream(){if(global.GCLOUD_SANDBOX_ENV){return new stream_1.PassThrough({objectMode:true})}prepareGaxRequest((err,requestFn)=>{if(err){stream.destroy(err);return}gaxStream=requestFn();gaxStream.on("error",err=>{stream.destroy(err)}).pipe(stream)});return}return stream}async setAclForBucket_(config){const bucket=config.destination;await bucket.acl.owners.addGroup("cloud-logs@google.com");config.destination="storage.googleapis.com/"+bucket.name}async setAclForDataset_(config){const dataset=config.destination;const[metadata]=await dataset.getMetadata();const access=[].slice.call(arrify(metadata.access));access.push({role:"WRITER",groupByEmail:"cloud-logs@google.com"});await dataset.setMetadata({access:access});const baseUrl="bigquery.googleapis.com";const pId=dataset.parent.projectId;const dId=dataset.id;config.destination=`${baseUrl}/projects/${pId}/datasets/${dId}`}async setAclForTopic_(config){const topic=config.destination;const[policy]=await topic.iam.getPolicy();policy.bindings=arrify(policy.bindings);policy.bindings.push({role:"roles/pubsub.publisher",members:["serviceAccount:cloud-logs@system.gserviceaccount.com"]});await topic.iam.setPolicy(policy);const baseUrl="pubsub.googleapis.com";const topicName=topic.name;config.destination=`${baseUrl}/${topicName}`}async setProjectId(reqOpts){if(this.projectId==="{{projectId}}")this.projectId=await this.auth.getProjectId();if(reqOpts)reqOpts=(0,projectify_1.replaceProjectIdToken)(reqOpts,this.projectId)}async setDetectedResource(){if(!this.detectedResource){this.detectedResource=await(0,metadata_1.getDefaultResource)(this.auth)}}}exports.Logging=Logging;(0,promisify_1.callbackifyAll)(Logging,{exclude:["request"]});paginator_1.paginator.extend(Logging,["getEntries","getLogs","getSinks"]);module.exports.v2=v2;const protos=require("../protos/protos");exports.protos=protos;
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.v2=exports.protos=exports.Logging=exports.Sink=exports.LogSync=exports.formatLogName=exports.assignSeverityToEntries=exports.Severity=exports.Log=exports.Entry=exports.detectServiceContext=exports.middleware=void 0;const common_1=require("@google-cloud/common");const paginator_1=require("@google-cloud/paginator");const projectify_1=require("@google-cloud/projectify");const promisify_1=require("@google-cloud/promisify");const arrify=require("arrify");const extend=require("extend");const gax=require("google-gax");const pumpify=require("pumpify");const streamEvents=require("stream-events");const middleware=require("./middleware");exports.middleware=middleware;const metadata_1=require("./utils/metadata");Object.defineProperty(exports,"detectServiceContext",{enumerable:true,get:function(){return metadata_1.detectServiceContext}});const version=require("../../package.json").version;const v2=require("./v2");exports.v2=v2;const entry_1=require("./entry");Object.defineProperty(exports,"Entry",{enumerable:true,get:function(){return entry_1.Entry}});const log_common_1=require("./utils/log-common");Object.defineProperty(exports,"Severity",{enumerable:true,get:function(){return log_common_1.Severity}});Object.defineProperty(exports,"formatLogName",{enumerable:true,get:function(){return log_common_1.formatLogName}});Object.defineProperty(exports,"assignSeverityToEntries",{enumerable:true,get:function(){return log_common_1.assignSeverityToEntries}});const log_1=require("./log");Object.defineProperty(exports,"Log",{enumerable:true,get:function(){return log_1.Log}});const log_sync_1=require("./log-sync");Object.defineProperty(exports,"LogSync",{enumerable:true,get:function(){return log_sync_1.LogSync}});const sink_1=require("./sink");Object.defineProperty(exports,"Sink",{enumerable:true,get:function(){return sink_1.Sink}});const stream_1=require("stream");class Logging{constructor(options){const scopes=[];const clientClasses=[v2.ConfigServiceV2Client,v2.LoggingServiceV2Client,v2.MetricsServiceV2Client];for(const clientClass of clientClasses){for(const scope of clientClass.scopes){if(scopes.indexOf(scope)===-1){scopes.push(scope)}}}const options_=extend({libName:"gccl",libVersion:version,scopes:scopes},options);this.api={};this.auth=new gax.GoogleAuth(options_);this.options=options_;this.projectId=this.options.projectId||"{{projectId}}";this.configService=new v2.ConfigServiceV2Client(this.options);this.loggingService=new v2.LoggingServiceV2Client(this.options)}async createSink(name,config){if(typeof name!=="string"){throw new Error("A sink name must be provided.")}if(typeof config!=="object"){throw new Error("A sink configuration object must be provided.")}if(common_1.util.isCustomType(config.destination,"bigquery/dataset")){await this.setAclForDataset_(config)}if(common_1.util.isCustomType(config.destination,"pubsub/topic")){await this.setAclForTopic_(config)}if(common_1.util.isCustomType(config.destination,"storage/bucket")){await this.setAclForBucket_(config)}const reqOpts={parent:"projects/"+this.projectId,sink:extend({},config,{name:name}),uniqueWriterIdentity:config.uniqueWriterIdentity};delete reqOpts.sink.gaxOptions;delete reqOpts.sink.uniqueWriterIdentity;await this.setProjectId(reqOpts);const[resp]=await this.configService.createSink(reqOpts,config.gaxOptions);const sink=this.sink(resp.name);sink.metadata=resp;return[sink,resp]}entry(resource,data){return new entry_1.Entry(resource,data)}async getEntries(opts){const options=opts?opts:{};let reqOpts=extend({orderBy:"timestamp desc"},options);const time=new Date;time.setDate(time.getDate()-1);const timeFilter=`timestamp >= "${time.toISOString()}"`;if(!options.filter){reqOpts=extend({filter:timeFilter},reqOpts)}else if(!options.filter.includes("timestamp")){reqOpts.filter+=` AND ${timeFilter}`}reqOpts.resourceNames=arrify(reqOpts.resourceNames);this.projectId=await this.auth.getProjectId();const resourceName="projects/"+this.projectId;if(reqOpts.resourceNames.indexOf(resourceName)===-1){reqOpts.resourceNames.push(resourceName)}delete reqOpts.autoPaginate;delete reqOpts.gaxOptions;const gaxOptions=extend({autoPaginate:options.autoPaginate},options.gaxOptions);const resp=await this.loggingService.listLogEntries(reqOpts,gaxOptions);const[entries]=resp;if(entries){resp[0]=entries.map(entry_1.Entry.fromApiResponse_)}return resp}getEntriesStream(options={}){let requestStream;const userStream=streamEvents(pumpify.obj());userStream.abort=()=>{if(requestStream){requestStream.abort()}};const toEntryStream=new stream_1.Transform({objectMode:true,transform:(chunk,encoding,callback)=>{callback(null,entry_1.Entry.fromApiResponse_(chunk))}});userStream.once("reading",()=>{this.auth.getProjectId().then(projectId=>{this.projectId=projectId;if(options.log){if(options.filter){options.filter=`(${options.filter}) AND logName="${(0,log_common_1.formatLogName)(this.projectId,options.log)}"`}else{options.filter=`logName="${(0,log_common_1.formatLogName)(this.projectId,options.log)}"`}delete options.log}const reqOpts=extend({orderBy:"timestamp desc"},options);reqOpts.resourceNames=arrify(reqOpts.resourceNames);reqOpts.resourceNames.push(`projects/${this.projectId}`);delete reqOpts.autoPaginate;delete reqOpts.gaxOptions;const gaxOptions=extend({autoPaginate:options.autoPaginate},options.gaxOptions);let gaxStream;requestStream=streamEvents(new stream_1.PassThrough({objectMode:true}));requestStream.abort=()=>{if(gaxStream&&gaxStream.cancel){gaxStream.cancel()}};if(!global.GCLOUD_SANDBOX_ENV){requestStream.once("reading",()=>{try{gaxStream=this.loggingService.listLogEntriesStream(reqOpts,gaxOptions)}catch(error){requestStream.destroy(error);return}gaxStream.on("error",err=>{requestStream.destroy(err)}).pipe(requestStream);return})}userStream.setPipeline(requestStream,toEntryStream)})});return userStream}tailEntries(options={}){const userStream=streamEvents(pumpify.obj());let gaxStream;userStream.abort=()=>{if(gaxStream&&gaxStream.cancel){gaxStream.cancel()}};const transformStream=new stream_1.Transform({objectMode:true,transform:(chunk,encoding,callback)=>{callback(null,(()=>{const formattedEntries=[];chunk.entries.forEach(entry=>{formattedEntries.push(entry_1.Entry.fromApiResponse_(entry))});const resp={entries:formattedEntries,suppressionInfo:chunk.suppressionInfo};return resp})())}});this.auth.getProjectId().then(projectId=>{this.projectId=projectId;if(options.log){if(options.filter){options.filter=`(${options.filter}) AND logName="${(0,log_common_1.formatLogName)(this.projectId,options.log)}"`}else{options.filter=`logName="${(0,log_common_1.formatLogName)(this.projectId,options.log)}"`}}options.resourceNames=arrify(options.resourceNames);options.resourceNames.push(`projects/${this.projectId}`);const writeOptions={resourceNames:options.resourceNames,...options.filter&&{filter:options.filter},...options.bufferWindow&&{bufferwindow:options.bufferWindow}};if(!global.GCLOUD_SANDBOX_ENV){gaxStream=this.loggingService.tailLogEntries(options.gaxOptions);gaxStream.write(writeOptions);userStream.setPipeline(gaxStream,transformStream)}});return userStream}async getLogs(opts){const options=opts?opts:{};this.projectId=await this.auth.getProjectId();const reqOpts=extend({},options,{parent:"projects/"+this.projectId});delete reqOpts.autoPaginate;delete reqOpts.gaxOptions;const gaxOptions=extend({autoPaginate:options.autoPaginate},options.gaxOptions);const resp=await this.loggingService.listLogs(reqOpts,gaxOptions);const[logs]=resp;if(logs){resp[0]=logs.map(logName=>this.log(logName))}return resp}getLogsStream(options={}){options=options||{};let requestStream;const userStream=streamEvents(pumpify.obj());userStream.abort=()=>{if(requestStream){requestStream.abort()}};const toLogStream=new stream_1.Transform({objectMode:true,transform:(chunk,encoding,callback)=>{callback(null,this.log(chunk))}});userStream.once("reading",()=>{this.auth.getProjectId().then(projectId=>{this.projectId=projectId;const reqOpts=extend({},options,{parent:"projects/"+this.projectId});delete reqOpts.gaxOptions;const gaxOptions=extend({autoPaginate:options.autoPaginate},options.gaxOptions);let gaxStream;requestStream=streamEvents(new stream_1.PassThrough({objectMode:true}));requestStream.abort=()=>{if(gaxStream&&gaxStream.cancel){gaxStream.cancel()}};requestStream.once("reading",()=>{try{gaxStream=this.loggingService.listLogsStream(reqOpts,gaxOptions)}catch(error){requestStream.destroy(error);return}gaxStream.on("error",err=>{requestStream.destroy(err)}).pipe(requestStream);return});userStream.setPipeline(requestStream,toLogStream)})});return userStream}async getSinks(opts){const options=opts?opts:{};this.projectId=await this.auth.getProjectId();const reqOpts=extend({},options,{parent:"projects/"+this.projectId});delete reqOpts.autoPaginate;delete reqOpts.gaxOptions;const gaxOptions=extend({autoPaginate:options.autoPaginate},options.gaxOptions);const resp=await this.configService.listSinks(reqOpts,gaxOptions);const[sinks]=resp;if(sinks){resp[0]=sinks.map(sink=>{const sinkInstance=this.sink(sink.name);sinkInstance.metadata=sink;return sinkInstance})}return resp}getSinksStream(options){const self=this;options=options||{};let requestStream;const userStream=streamEvents(pumpify.obj());userStream.abort=()=>{if(requestStream){requestStream.abort()}};const toSinkStream=new stream_1.Transform({objectMode:true,transform:(chunk,encoding,callback)=>{const sinkInstance=self.sink(chunk.name);sinkInstance.metadata=chunk;callback(null,sinkInstance)}});userStream.once("reading",()=>{this.auth.getProjectId().then(projectId=>{this.projectId=projectId;const reqOpts=extend({},options,{parent:"projects/"+self.projectId});delete reqOpts.gaxOptions;const gaxOptions=extend({autoPaginate:options.autoPaginate},options.gaxOptions);let gaxStream;requestStream=streamEvents(new stream_1.PassThrough({objectMode:true}));requestStream.abort=()=>{if(gaxStream&&gaxStream.cancel){gaxStream.cancel()}};if(!global.GCLOUD_SANDBOX_ENV){requestStream.once("reading",()=>{try{gaxStream=this.configService.listSinksStream(reqOpts,gaxOptions)}catch(error){requestStream.destroy(error);return}gaxStream.on("error",err=>{requestStream.destroy(err)}).pipe(requestStream);return})}userStream.setPipeline(requestStream,toSinkStream)})});return userStream}log(name,options){return new log_1.Log(this,name,options)}logSync(name,transport,options){return new log_sync_1.LogSync(this,name,transport,options)}sink(name){return new sink_1.Sink(this,name)}request(config,callback){const self=this;const isStreamMode=!callback;let gaxStream;let stream;if(isStreamMode){stream=streamEvents(new stream_1.PassThrough({objectMode:true}));stream.abort=()=>{if(gaxStream&&gaxStream.cancel){gaxStream.cancel()}};stream.once("reading",makeRequestStream)}else{makeRequestCallback()}function prepareGaxRequest(callback){self.auth.getProjectId((err,projectId)=>{if(err){callback(err);return}self.projectId=projectId;let gaxClient=self.api[config.client];if(!gaxClient){gaxClient=new v2[config.client](self.options);self.api[config.client]=gaxClient}let reqOpts=extend(true,{},config.reqOpts);reqOpts=(0,projectify_1.replaceProjectIdToken)(reqOpts,projectId);const requestFn=gaxClient[config.method].bind(gaxClient,reqOpts,config.gaxOpts);callback(null,requestFn)})}function makeRequestCallback(){if(global.GCLOUD_SANDBOX_ENV){return}prepareGaxRequest((err,requestFn)=>{if(err){callback(err);return}requestFn(callback)})}function makeRequestStream(){if(global.GCLOUD_SANDBOX_ENV){return new stream_1.PassThrough({objectMode:true})}prepareGaxRequest((err,requestFn)=>{if(err){stream.destroy(err);return}gaxStream=requestFn();gaxStream.on("error",err=>{stream.destroy(err)}).pipe(stream)});return}return stream}async setAclForBucket_(config){const bucket=config.destination;await bucket.acl.owners.addGroup("cloud-logs@google.com");config.destination="storage.googleapis.com/"+bucket.name}async setAclForDataset_(config){const dataset=config.destination;const[metadata]=await dataset.getMetadata();const access=[].slice.call(arrify(metadata.access));access.push({role:"WRITER",groupByEmail:"cloud-logs@google.com"});await dataset.setMetadata({access:access});const baseUrl="bigquery.googleapis.com";const pId=dataset.parent.projectId;const dId=dataset.id;config.destination=`${baseUrl}/projects/${pId}/datasets/${dId}`}async setAclForTopic_(config){const topic=config.destination;const[policy]=await topic.iam.getPolicy();policy.bindings=arrify(policy.bindings);policy.bindings.push({role:"roles/pubsub.publisher",members:["serviceAccount:cloud-logs@system.gserviceaccount.com"]});await topic.iam.setPolicy(policy);const baseUrl="pubsub.googleapis.com";const topicName=topic.name;config.destination=`${baseUrl}/${topicName}`}async setProjectId(reqOpts){if(this.projectId==="{{projectId}}")this.projectId=await this.auth.getProjectId();if(reqOpts)reqOpts=(0,projectify_1.replaceProjectIdToken)(reqOpts,this.projectId)}async setDetectedResource(){if(!this.detectedResource){this.detectedResource=await(0,metadata_1.getDefaultResource)(this.auth)}}}exports.Logging=Logging;(0,promisify_1.callbackifyAll)(Logging,{exclude:["request"]});paginator_1.paginator.extend(Logging,["getEntries","getLogs","getSinks"]);module.exports.v2=v2;const protos=require("../protos/protos");exports.protos=protos;
//# sourceMappingURL=index.js.map
{
"name": "@google-cloud/logging-min",
"version": "10.1.0",
"version": "10.1.1",
"description": "Stackdriver Logging Client Library for Node.js",

@@ -84,3 +84,3 @@ "keywords": [

"jsdoc-region-tag": "^2.0.0",
"linkinator": "^2.0.3",
"linkinator": "^4.0.0",
"mocha": "^9.2.2",

@@ -87,0 +87,0 @@ "nock": "^13.0.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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