@google-cloud/logging-min
Advanced tools
Comparing version 9.6.8 to 9.6.9
@@ -49,2 +49,3 @@ /*! | ||
jsonFieldsToTruncate?: string[]; | ||
defaultWriteDeleteCallback?: ApiResponseCallback; | ||
} | ||
@@ -76,8 +77,24 @@ export declare type Metadata = any; | ||
* Received values will be prepended to predefined list in the order received and duplicates discarded. | ||
* | ||
* @param {ApiResponseCallback} [options.defaultWriteDeleteCallback] A default global callback to be used for {@link Log#write} | ||
* and {@link Log#delete} APIs when {@link ApiResponseCallback} callback was not supplied by caller in function parameters. | ||
* Note that {@link LogOptions#defaultWriteDeleteCallback} is useful when {@link Log#write} and {@link Log#delete} APIs are called | ||
* without `await` and without callback added explicitly to every call - this way {@link LogOptions#defaultWriteDeleteCallback} | ||
* can serve as global callback handler, which for example could be used to catch all errors and eliminate crashes. | ||
* @example | ||
* ``` | ||
* const {Logging} = require('@google-cloud/logging'); | ||
* import {Logging} from '@google-cloud/logging'; | ||
* import {LogOptions} from '@google-cloud/logging/build/src/log'; | ||
* const options: LogOptions = { | ||
* maxEntrySize: 256, | ||
* jsonFieldsToTruncate: [ | ||
* 'jsonPayload.fields.metadata.structValue.fields.custom.stringValue', | ||
* ], | ||
* defaultWriteDeleteCallback: (err: any) => { | ||
* if (err) { | ||
* console.log('Error: ' + err); | ||
* } | ||
* }, | ||
* }; | ||
* const logging = new Logging(); | ||
* const log = logging.log('syslog'); | ||
* const log = logging.log('syslog', options); | ||
* ``` | ||
@@ -92,2 +109,3 @@ */ | ||
jsonFieldsToTruncate: string[]; | ||
defaultWriteDeleteCallback?: ApiResponseCallback; | ||
constructor(logging: Logging, name: string, options?: LogOptions); | ||
@@ -94,0 +112,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.Log=void 0;const arrify=require("arrify");const promisify_1=require("@google-cloud/promisify");const dotProp=require("dot-prop");const extend=require("extend");const entry_1=require("./entry");const log_common_1=require("./utils/log-common");class Log{constructor(logging,name,options){options=options||{};this.formattedName_=log_common_1.formatLogName(logging.projectId,name);this.removeCircular_=options.removeCircular===true;this.maxEntrySize=options.maxEntrySize;this.logging=logging;this.name=this.formattedName_.split("/").pop();this.jsonFieldsToTruncate=["jsonPayload.fields.metadata.structValue.fields.stack.stringValue","jsonPayload.fields.msg.stringValue","jsonPayload.fields.err.structValue.fields.stack.stringValue","jsonPayload.fields.err.structValue.fields.message.stringValue","jsonPayload.fields.message.stringValue"];if(options.jsonFieldsToTruncate!==null&&options.jsonFieldsToTruncate!==undefined){const filteredList=options.jsonFieldsToTruncate.filter(str=>str!==null&&!this.jsonFieldsToTruncate.includes(str)&&str.startsWith("jsonPayload"));const uniqueSet=new Set(filteredList);this.jsonFieldsToTruncate=Array.from(uniqueSet).concat(this.jsonFieldsToTruncate)}}alert(entry,options){return this.write(log_common_1.assignSeverityToEntries(entry,"ALERT"),options)}critical(entry,options){return this.write(log_common_1.assignSeverityToEntries(entry,"CRITICAL"),options)}debug(entry,options){return this.write(log_common_1.assignSeverityToEntries(entry,"DEBUG"),options)}async delete(gaxOptions){const projectId=await this.logging.auth.getProjectId();this.formattedName_=log_common_1.formatLogName(projectId,this.name);const reqOpts={logName:this.formattedName_};return this.logging.loggingService.deleteLog(reqOpts,gaxOptions)}emergency(entry,options){return this.write(log_common_1.assignSeverityToEntries(entry,"EMERGENCY"),options)}entry(metadataOrData,data){let metadata;if(!data&&metadataOrData!==null&&Object.prototype.hasOwnProperty.call(metadataOrData,"httpRequest")){metadata=metadataOrData;data={}}else if(!data){data=metadataOrData;metadata={}}else{metadata=metadataOrData}return this.logging.entry(metadata,data)}error(entry,options){return this.write(log_common_1.assignSeverityToEntries(entry,"ERROR"),options)}async getEntries(opts){const options=extend({},opts);const projectId=await this.logging.auth.getProjectId();this.formattedName_=log_common_1.formatLogName(projectId,this.name);if(options.filter&&!options.filter.includes("logName=")){options.filter=`(${options.filter}) AND logName="${this.formattedName_}"`}else if(!options.filter){options.filter=`logName="${this.formattedName_}"`}return this.logging.getEntries(options)}getEntriesStream(options){options=extend({log:this.name},options);return this.logging.getEntriesStream(options)}tailEntries(options){options=extend({log:this.name},options);return this.logging.tailEntries(options)}info(entry,options){return this.write(log_common_1.assignSeverityToEntries(entry,"INFO"),options)}notice(entry,options){return this.write(log_common_1.assignSeverityToEntries(entry,"NOTICE"),options)}warning(entry,options){return this.write(log_common_1.assignSeverityToEntries(entry,"WARNING"),options)}async write(entry,opts){const options=opts?opts:{};await this.logging.setProjectId();this.formattedName_=log_common_1.formatLogName(this.logging.projectId,this.name);const resource=await this.getOrSetResource(options);const decoratedEntries=this.decorateEntries(arrify(entry));this.truncateEntries(decoratedEntries);const reqOpts=extend({logName:this.formattedName_,entries:decoratedEntries,resource:resource},options);delete reqOpts.gaxOptions;return this.logging.loggingService.writeLogEntries(reqOpts,options.gaxOptions)}async getOrSetResource(options){if(options.resource){if(options.resource.labels)log_common_1.snakecaseKeys(options.resource.labels);return options.resource}await this.logging.setDetectedResource();return this.logging.detectedResource}decorateEntries(entries){return entries.map(entry=>{if(!(entry instanceof entry_1.Entry)){entry=this.entry(entry)}return entry.toJSON({removeCircular:this.removeCircular_},this.logging.projectId)})}truncateEntries(entries){return entries.forEach(entry=>{if(this.maxEntrySize===undefined)return;const payloadSize=JSON.stringify(entry).length;if(payloadSize<this.maxEntrySize)return;let delta=payloadSize-this.maxEntrySize;if(entry.textPayload){entry.textPayload=entry.textPayload.slice(0,Math.max(entry.textPayload.length-delta,0))}else{for(const field of this.jsonFieldsToTruncate){const msg=dotProp.get(entry,field,"");if(msg!==null&&msg!==undefined&&msg!==""){dotProp.set(entry,field,msg.slice(0,Math.max(msg.length-delta,0)));delta-=Math.min(msg.length,delta);if(delta<=0){break}}}}})}static assignSeverityToEntries_(entries,severity){return log_common_1.assignSeverityToEntries(entries,severity)}static formatName_(projectId,name){return log_common_1.formatLogName(projectId,name)}}exports.Log=Log;promisify_1.callbackifyAll(Log,{exclude:["entry","getEntriesStream"]}); | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.Log=void 0;const arrify=require("arrify");const promisify_1=require("@google-cloud/promisify");const dotProp=require("dot-prop");const extend=require("extend");const entry_1=require("./entry");const log_common_1=require("./utils/log-common");class Log{constructor(logging,name,options){options=options||{};this.formattedName_=log_common_1.formatLogName(logging.projectId,name);this.removeCircular_=options.removeCircular===true;this.maxEntrySize=options.maxEntrySize;this.logging=logging;this.name=this.formattedName_.split("/").pop();this.jsonFieldsToTruncate=["jsonPayload.fields.metadata.structValue.fields.stack.stringValue","jsonPayload.fields.msg.stringValue","jsonPayload.fields.err.structValue.fields.stack.stringValue","jsonPayload.fields.err.structValue.fields.message.stringValue","jsonPayload.fields.message.stringValue"];if(options.jsonFieldsToTruncate!==null&&options.jsonFieldsToTruncate!==undefined){const filteredList=options.jsonFieldsToTruncate.filter(str=>str!==null&&!this.jsonFieldsToTruncate.includes(str)&&str.startsWith("jsonPayload"));const uniqueSet=new Set(filteredList);this.jsonFieldsToTruncate=Array.from(uniqueSet).concat(this.jsonFieldsToTruncate)}this.defaultWriteDeleteCallback=options.defaultWriteDeleteCallback}alert(entry,options){return this.write(log_common_1.assignSeverityToEntries(entry,"ALERT"),options)}critical(entry,options){return this.write(log_common_1.assignSeverityToEntries(entry,"CRITICAL"),options)}debug(entry,options){return this.write(log_common_1.assignSeverityToEntries(entry,"DEBUG"),options)}async delete(gaxOptions){const projectId=await this.logging.auth.getProjectId();this.formattedName_=log_common_1.formatLogName(projectId,this.name);const reqOpts={logName:this.formattedName_};return this.logging.loggingService.deleteLog(reqOpts,gaxOptions,this.defaultWriteDeleteCallback)}emergency(entry,options){return this.write(log_common_1.assignSeverityToEntries(entry,"EMERGENCY"),options)}entry(metadataOrData,data){let metadata;if(!data&&metadataOrData!==null&&Object.prototype.hasOwnProperty.call(metadataOrData,"httpRequest")){metadata=metadataOrData;data={}}else if(!data){data=metadataOrData;metadata={}}else{metadata=metadataOrData}return this.logging.entry(metadata,data)}error(entry,options){return this.write(log_common_1.assignSeverityToEntries(entry,"ERROR"),options)}async getEntries(opts){const options=extend({},opts);const projectId=await this.logging.auth.getProjectId();this.formattedName_=log_common_1.formatLogName(projectId,this.name);if(options.filter&&!options.filter.includes("logName=")){options.filter=`(${options.filter}) AND logName="${this.formattedName_}"`}else if(!options.filter){options.filter=`logName="${this.formattedName_}"`}return this.logging.getEntries(options)}getEntriesStream(options){options=extend({log:this.name},options);return this.logging.getEntriesStream(options)}tailEntries(options){options=extend({log:this.name},options);return this.logging.tailEntries(options)}info(entry,options){return this.write(log_common_1.assignSeverityToEntries(entry,"INFO"),options)}notice(entry,options){return this.write(log_common_1.assignSeverityToEntries(entry,"NOTICE"),options)}warning(entry,options){return this.write(log_common_1.assignSeverityToEntries(entry,"WARNING"),options)}async write(entry,opts){const options=opts?opts:{};await this.logging.setProjectId();this.formattedName_=log_common_1.formatLogName(this.logging.projectId,this.name);const resource=await this.getOrSetResource(options);const decoratedEntries=this.decorateEntries(arrify(entry));this.truncateEntries(decoratedEntries);const reqOpts=extend({logName:this.formattedName_,entries:decoratedEntries,resource:resource},options);delete reqOpts.gaxOptions;return this.logging.loggingService.writeLogEntries(reqOpts,options.gaxOptions,this.defaultWriteDeleteCallback)}async getOrSetResource(options){if(options.resource){if(options.resource.labels)log_common_1.snakecaseKeys(options.resource.labels);return options.resource}await this.logging.setDetectedResource();return this.logging.detectedResource}decorateEntries(entries){return entries.map(entry=>{if(!(entry instanceof entry_1.Entry)){entry=this.entry(entry)}return entry.toJSON({removeCircular:this.removeCircular_},this.logging.projectId)})}truncateEntries(entries){return entries.forEach(entry=>{if(this.maxEntrySize===undefined)return;const payloadSize=JSON.stringify(entry).length;if(payloadSize<this.maxEntrySize)return;let delta=payloadSize-this.maxEntrySize;if(entry.textPayload){entry.textPayload=entry.textPayload.slice(0,Math.max(entry.textPayload.length-delta,0))}else{for(const field of this.jsonFieldsToTruncate){const msg=dotProp.get(entry,field,"");if(msg!==null&&msg!==undefined&&msg!==""){dotProp.set(entry,field,msg.slice(0,Math.max(msg.length-delta,0)));delta-=Math.min(msg.length,delta);if(delta<=0){break}}}}})}static assignSeverityToEntries_(entries,severity){return log_common_1.assignSeverityToEntries(entries,severity)}static formatName_(projectId,name){return log_common_1.formatLogName(projectId,name)}}exports.Log=Log;promisify_1.callbackifyAll(Log,{exclude:["entry","getEntriesStream"]}); | ||
//# sourceMappingURL=log.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.LoggingServiceV2Client=void 0;const gax=require("google-gax");const jsonProtos=require("../../protos/protos.json");const gapicConfig=require("./logging_service_v2_client_config.json");const version=require("../../../package.json").version;class LoggingServiceV2Client{constructor(opts){var _a,_b;this._terminated=false;this.descriptors={page:{},stream:{},longrunning:{},batching:{}};const staticMembers=this.constructor;const servicePath=(opts===null||opts===void 0?void 0:opts.servicePath)||(opts===null||opts===void 0?void 0:opts.apiEndpoint)||staticMembers.servicePath;this._providedCustomServicePath=!!((opts===null||opts===void 0?void 0:opts.servicePath)||(opts===null||opts===void 0?void 0:opts.apiEndpoint));const port=(opts===null||opts===void 0?void 0:opts.port)||staticMembers.port;const clientConfig=(_a=opts===null||opts===void 0?void 0:opts.clientConfig)!==null&&_a!==void 0?_a:{};const fallback=(_b=opts===null||opts===void 0?void 0:opts.fallback)!==null&&_b!==void 0?_b:typeof window!=="undefined"&&typeof(window===null||window===void 0?void 0:window.fetch)==="function";opts=Object.assign({servicePath:servicePath,port:port,clientConfig:clientConfig,fallback:fallback},opts);if(servicePath!==staticMembers.servicePath&&!("scopes"in opts)){opts["scopes"]=staticMembers.scopes}this._gaxModule=opts.fallback?gax.fallback:gax;this._gaxGrpc=new this._gaxModule.GrpcClient(opts);this._opts=opts;this.auth=this._gaxGrpc.auth;this.auth.useJWTAccessWithScope=true;this.auth.defaultServicePath=staticMembers.servicePath;if(servicePath===staticMembers.servicePath){this.auth.defaultScopes=staticMembers.scopes}const clientHeader=[`gax/${this._gaxModule.version}`,`gapic/${version}`];if(typeof process!=="undefined"&&"versions"in process){clientHeader.push(`gl-node/${process.versions.node}`)}else{clientHeader.push(`gl-web/${this._gaxModule.version}`)}if(!opts.fallback){clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`)}else if(opts.fallback==="rest"){clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`)}if(opts.libName&&opts.libVersion){clientHeader.push(`${opts.libName}/${opts.libVersion}`)}this._protos=this._gaxGrpc.loadProtoJSON(jsonProtos);this.pathTemplates={billingAccountCmekSettingsPathTemplate:new this._gaxModule.PathTemplate("billingAccounts/{billing_account}/cmekSettings"),billingAccountExclusionPathTemplate:new this._gaxModule.PathTemplate("billingAccounts/{billing_account}/exclusions/{exclusion}"),billingAccountLocationBucketPathTemplate:new this._gaxModule.PathTemplate("billingAccounts/{billing_account}/locations/{location}/buckets/{bucket}"),billingAccountLocationBucketViewPathTemplate:new this._gaxModule.PathTemplate("billingAccounts/{billing_account}/locations/{location}/buckets/{bucket}/views/{view}"),billingAccountLogPathTemplate:new this._gaxModule.PathTemplate("billingAccounts/{billing_account}/logs/{log}"),billingAccountSinkPathTemplate:new this._gaxModule.PathTemplate("billingAccounts/{billing_account}/sinks/{sink}"),folderCmekSettingsPathTemplate:new this._gaxModule.PathTemplate("folders/{folder}/cmekSettings"),folderExclusionPathTemplate:new this._gaxModule.PathTemplate("folders/{folder}/exclusions/{exclusion}"),folderLocationBucketPathTemplate:new this._gaxModule.PathTemplate("folders/{folder}/locations/{location}/buckets/{bucket}"),folderLocationBucketViewPathTemplate:new this._gaxModule.PathTemplate("folders/{folder}/locations/{location}/buckets/{bucket}/views/{view}"),folderLogPathTemplate:new this._gaxModule.PathTemplate("folders/{folder}/logs/{log}"),folderSinkPathTemplate:new this._gaxModule.PathTemplate("folders/{folder}/sinks/{sink}"),logMetricPathTemplate:new this._gaxModule.PathTemplate("projects/{project}/metrics/{metric}"),organizationCmekSettingsPathTemplate:new this._gaxModule.PathTemplate("organizations/{organization}/cmekSettings"),organizationExclusionPathTemplate:new this._gaxModule.PathTemplate("organizations/{organization}/exclusions/{exclusion}"),organizationLocationBucketPathTemplate:new this._gaxModule.PathTemplate("organizations/{organization}/locations/{location}/buckets/{bucket}"),organizationLocationBucketViewPathTemplate:new this._gaxModule.PathTemplate("organizations/{organization}/locations/{location}/buckets/{bucket}/views/{view}"),organizationLogPathTemplate:new this._gaxModule.PathTemplate("organizations/{organization}/logs/{log}"),organizationSinkPathTemplate:new this._gaxModule.PathTemplate("organizations/{organization}/sinks/{sink}"),projectPathTemplate:new this._gaxModule.PathTemplate("projects/{project}"),projectCmekSettingsPathTemplate:new this._gaxModule.PathTemplate("projects/{project}/cmekSettings"),projectExclusionPathTemplate:new this._gaxModule.PathTemplate("projects/{project}/exclusions/{exclusion}"),projectLocationBucketPathTemplate:new this._gaxModule.PathTemplate("projects/{project}/locations/{location}/buckets/{bucket}"),projectLocationBucketViewPathTemplate:new this._gaxModule.PathTemplate("projects/{project}/locations/{location}/buckets/{bucket}/views/{view}"),projectLogPathTemplate:new this._gaxModule.PathTemplate("projects/{project}/logs/{log}"),projectSinkPathTemplate:new this._gaxModule.PathTemplate("projects/{project}/sinks/{sink}")};this.descriptors.page={listLogEntries:new this._gaxModule.PageDescriptor("pageToken","nextPageToken","entries"),listMonitoredResourceDescriptors:new this._gaxModule.PageDescriptor("pageToken","nextPageToken","resourceDescriptors"),listLogs:new this._gaxModule.PageDescriptor("pageToken","nextPageToken","logNames")};this.descriptors.stream={tailLogEntries:new this._gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING)};const protoFilesRoot=this._gaxModule.protobuf.Root.fromJSON(jsonProtos);this.descriptors.batching={writeLogEntries:new this._gaxModule.BundleDescriptor("entries",["log_name","resource","labels"],null,gax.createByteLengthFunction(protoFilesRoot.lookupType("google.logging.v2.LogEntry")))};this._defaults=this._gaxGrpc.constructSettings("google.logging.v2.LoggingServiceV2",gapicConfig,opts.clientConfig||{},{"x-goog-api-client":clientHeader.join(" ")});this.innerApiCalls={};this.warn=gax.warn}initialize(){var _a;if(this.loggingServiceV2Stub){return this.loggingServiceV2Stub}this.loggingServiceV2Stub=this._gaxGrpc.createStub(this._opts.fallback?this._protos.lookupService("google.logging.v2.LoggingServiceV2"):this._protos.google.logging.v2.LoggingServiceV2,this._opts,this._providedCustomServicePath);const loggingServiceV2StubMethods=["deleteLog","writeLogEntries","listLogEntries","listMonitoredResourceDescriptors","listLogs","tailLogEntries"];for(const methodName of loggingServiceV2StubMethods){const callPromise=this.loggingServiceV2Stub.then(stub=>(...args)=>{if(this._terminated){return Promise.reject("The client has already been closed.")}const func=stub[methodName];return func.apply(stub,args)},err=>()=>{throw err});const descriptor=this.descriptors.page[methodName]||this.descriptors.stream[methodName]||((_a=this.descriptors.batching)===null||_a===void 0?void 0:_a[methodName])||undefined;const apiCall=this._gaxModule.createApiCall(callPromise,this._defaults[methodName],descriptor);this.innerApiCalls[methodName]=apiCall}return this.loggingServiceV2Stub}static get servicePath(){return"logging.googleapis.com"}static get apiEndpoint(){return"logging.googleapis.com"}static get port(){return 443}static get scopes(){return["https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloud-platform.read-only","https://www.googleapis.com/auth/logging.admin","https://www.googleapis.com/auth/logging.read","https://www.googleapis.com/auth/logging.write"]}getProjectId(callback){if(callback){this.auth.getProjectId(callback);return}return this.auth.getProjectId()}deleteLog(request,optionsOrCallback,callback){request=request||{};let options;if(typeof optionsOrCallback==="function"&&callback===undefined){callback=optionsOrCallback;options={}}else{options=optionsOrCallback}options=options||{};options.otherArgs=options.otherArgs||{};options.otherArgs.headers=options.otherArgs.headers||{};options.otherArgs.headers["x-goog-request-params"]=gax.routingHeader.fromParams({log_name:request.logName||""});this.initialize();return this.innerApiCalls.deleteLog(request,options,callback)}writeLogEntries(request,optionsOrCallback,callback){request=request||{};let options;if(typeof optionsOrCallback==="function"&&callback===undefined){callback=optionsOrCallback;options={}}else{options=optionsOrCallback}options=options||{};options.otherArgs=options.otherArgs||{};options.otherArgs.headers=options.otherArgs.headers||{};this.initialize();return this.innerApiCalls.writeLogEntries(request,options,callback)}tailLogEntries(options){this.initialize();return this.innerApiCalls.tailLogEntries(options)}listLogEntries(request,optionsOrCallback,callback){request=request||{};let options;if(typeof optionsOrCallback==="function"&&callback===undefined){callback=optionsOrCallback;options={}}else{options=optionsOrCallback}options=options||{};options.otherArgs=options.otherArgs||{};options.otherArgs.headers=options.otherArgs.headers||{};this.initialize();return this.innerApiCalls.listLogEntries(request,options,callback)}listLogEntriesStream(request,options){request=request||{};options=options||{};options.otherArgs=options.otherArgs||{};options.otherArgs.headers=options.otherArgs.headers||{};const defaultCallSettings=this._defaults["listLogEntries"];const callSettings=defaultCallSettings.merge(options);this.initialize();return this.descriptors.page.listLogEntries.createStream(this.innerApiCalls.listLogEntries,request,callSettings)}listLogEntriesAsync(request,options){request=request||{};options=options||{};options.otherArgs=options.otherArgs||{};options.otherArgs.headers=options.otherArgs.headers||{};const defaultCallSettings=this._defaults["listLogEntries"];const callSettings=defaultCallSettings.merge(options);this.initialize();return this.descriptors.page.listLogEntries.asyncIterate(this.innerApiCalls["listLogEntries"],request,callSettings)}listMonitoredResourceDescriptors(request,optionsOrCallback,callback){request=request||{};let options;if(typeof optionsOrCallback==="function"&&callback===undefined){callback=optionsOrCallback;options={}}else{options=optionsOrCallback}options=options||{};options.otherArgs=options.otherArgs||{};options.otherArgs.headers=options.otherArgs.headers||{};this.initialize();return this.innerApiCalls.listMonitoredResourceDescriptors(request,options,callback)}listMonitoredResourceDescriptorsStream(request,options){request=request||{};options=options||{};options.otherArgs=options.otherArgs||{};options.otherArgs.headers=options.otherArgs.headers||{};const defaultCallSettings=this._defaults["listMonitoredResourceDescriptors"];const callSettings=defaultCallSettings.merge(options);this.initialize();return this.descriptors.page.listMonitoredResourceDescriptors.createStream(this.innerApiCalls.listMonitoredResourceDescriptors,request,callSettings)}listMonitoredResourceDescriptorsAsync(request,options){request=request||{};options=options||{};options.otherArgs=options.otherArgs||{};options.otherArgs.headers=options.otherArgs.headers||{};const defaultCallSettings=this._defaults["listMonitoredResourceDescriptors"];const callSettings=defaultCallSettings.merge(options);this.initialize();return this.descriptors.page.listMonitoredResourceDescriptors.asyncIterate(this.innerApiCalls["listMonitoredResourceDescriptors"],request,callSettings)}listLogs(request,optionsOrCallback,callback){request=request||{};let options;if(typeof optionsOrCallback==="function"&&callback===undefined){callback=optionsOrCallback;options={}}else{options=optionsOrCallback}options=options||{};options.otherArgs=options.otherArgs||{};options.otherArgs.headers=options.otherArgs.headers||{};options.otherArgs.headers["x-goog-request-params"]=gax.routingHeader.fromParams({parent:request.parent||""});this.initialize();return this.innerApiCalls.listLogs(request,options,callback)}listLogsStream(request,options){request=request||{};options=options||{};options.otherArgs=options.otherArgs||{};options.otherArgs.headers=options.otherArgs.headers||{};options.otherArgs.headers["x-goog-request-params"]=gax.routingHeader.fromParams({parent:request.parent||""});const defaultCallSettings=this._defaults["listLogs"];const callSettings=defaultCallSettings.merge(options);this.initialize();return this.descriptors.page.listLogs.createStream(this.innerApiCalls.listLogs,request,callSettings)}listLogsAsync(request,options){request=request||{};options=options||{};options.otherArgs=options.otherArgs||{};options.otherArgs.headers=options.otherArgs.headers||{};options.otherArgs.headers["x-goog-request-params"]=gax.routingHeader.fromParams({parent:request.parent||""});const defaultCallSettings=this._defaults["listLogs"];const callSettings=defaultCallSettings.merge(options);this.initialize();return this.descriptors.page.listLogs.asyncIterate(this.innerApiCalls["listLogs"],request,callSettings)}billingAccountCmekSettingsPath(billingAccount){return this.pathTemplates.billingAccountCmekSettingsPathTemplate.render({billing_account:billingAccount})}matchBillingAccountFromBillingAccountCmekSettingsName(billingAccountCmekSettingsName){return this.pathTemplates.billingAccountCmekSettingsPathTemplate.match(billingAccountCmekSettingsName).billing_account}billingAccountExclusionPath(billingAccount,exclusion){return this.pathTemplates.billingAccountExclusionPathTemplate.render({billing_account:billingAccount,exclusion:exclusion})}matchBillingAccountFromBillingAccountExclusionName(billingAccountExclusionName){return this.pathTemplates.billingAccountExclusionPathTemplate.match(billingAccountExclusionName).billing_account}matchExclusionFromBillingAccountExclusionName(billingAccountExclusionName){return this.pathTemplates.billingAccountExclusionPathTemplate.match(billingAccountExclusionName).exclusion}billingAccountLocationBucketPath(billingAccount,location,bucket){return this.pathTemplates.billingAccountLocationBucketPathTemplate.render({billing_account:billingAccount,location:location,bucket:bucket})}matchBillingAccountFromBillingAccountLocationBucketName(billingAccountLocationBucketName){return this.pathTemplates.billingAccountLocationBucketPathTemplate.match(billingAccountLocationBucketName).billing_account}matchLocationFromBillingAccountLocationBucketName(billingAccountLocationBucketName){return this.pathTemplates.billingAccountLocationBucketPathTemplate.match(billingAccountLocationBucketName).location}matchBucketFromBillingAccountLocationBucketName(billingAccountLocationBucketName){return this.pathTemplates.billingAccountLocationBucketPathTemplate.match(billingAccountLocationBucketName).bucket}billingAccountLocationBucketViewPath(billingAccount,location,bucket,view){return this.pathTemplates.billingAccountLocationBucketViewPathTemplate.render({billing_account:billingAccount,location:location,bucket:bucket,view:view})}matchBillingAccountFromBillingAccountLocationBucketViewName(billingAccountLocationBucketViewName){return this.pathTemplates.billingAccountLocationBucketViewPathTemplate.match(billingAccountLocationBucketViewName).billing_account}matchLocationFromBillingAccountLocationBucketViewName(billingAccountLocationBucketViewName){return this.pathTemplates.billingAccountLocationBucketViewPathTemplate.match(billingAccountLocationBucketViewName).location}matchBucketFromBillingAccountLocationBucketViewName(billingAccountLocationBucketViewName){return this.pathTemplates.billingAccountLocationBucketViewPathTemplate.match(billingAccountLocationBucketViewName).bucket}matchViewFromBillingAccountLocationBucketViewName(billingAccountLocationBucketViewName){return this.pathTemplates.billingAccountLocationBucketViewPathTemplate.match(billingAccountLocationBucketViewName).view}billingAccountLogPath(billingAccount,log){return this.pathTemplates.billingAccountLogPathTemplate.render({billing_account:billingAccount,log:log})}matchBillingAccountFromBillingAccountLogName(billingAccountLogName){return this.pathTemplates.billingAccountLogPathTemplate.match(billingAccountLogName).billing_account}matchLogFromBillingAccountLogName(billingAccountLogName){return this.pathTemplates.billingAccountLogPathTemplate.match(billingAccountLogName).log}billingAccountSinkPath(billingAccount,sink){return this.pathTemplates.billingAccountSinkPathTemplate.render({billing_account:billingAccount,sink:sink})}matchBillingAccountFromBillingAccountSinkName(billingAccountSinkName){return this.pathTemplates.billingAccountSinkPathTemplate.match(billingAccountSinkName).billing_account}matchSinkFromBillingAccountSinkName(billingAccountSinkName){return this.pathTemplates.billingAccountSinkPathTemplate.match(billingAccountSinkName).sink}folderCmekSettingsPath(folder){return this.pathTemplates.folderCmekSettingsPathTemplate.render({folder:folder})}matchFolderFromFolderCmekSettingsName(folderCmekSettingsName){return this.pathTemplates.folderCmekSettingsPathTemplate.match(folderCmekSettingsName).folder}folderExclusionPath(folder,exclusion){return this.pathTemplates.folderExclusionPathTemplate.render({folder:folder,exclusion:exclusion})}matchFolderFromFolderExclusionName(folderExclusionName){return this.pathTemplates.folderExclusionPathTemplate.match(folderExclusionName).folder}matchExclusionFromFolderExclusionName(folderExclusionName){return this.pathTemplates.folderExclusionPathTemplate.match(folderExclusionName).exclusion}folderLocationBucketPath(folder,location,bucket){return this.pathTemplates.folderLocationBucketPathTemplate.render({folder:folder,location:location,bucket:bucket})}matchFolderFromFolderLocationBucketName(folderLocationBucketName){return this.pathTemplates.folderLocationBucketPathTemplate.match(folderLocationBucketName).folder}matchLocationFromFolderLocationBucketName(folderLocationBucketName){return this.pathTemplates.folderLocationBucketPathTemplate.match(folderLocationBucketName).location}matchBucketFromFolderLocationBucketName(folderLocationBucketName){return this.pathTemplates.folderLocationBucketPathTemplate.match(folderLocationBucketName).bucket}folderLocationBucketViewPath(folder,location,bucket,view){return this.pathTemplates.folderLocationBucketViewPathTemplate.render({folder:folder,location:location,bucket:bucket,view:view})}matchFolderFromFolderLocationBucketViewName(folderLocationBucketViewName){return this.pathTemplates.folderLocationBucketViewPathTemplate.match(folderLocationBucketViewName).folder}matchLocationFromFolderLocationBucketViewName(folderLocationBucketViewName){return this.pathTemplates.folderLocationBucketViewPathTemplate.match(folderLocationBucketViewName).location}matchBucketFromFolderLocationBucketViewName(folderLocationBucketViewName){return this.pathTemplates.folderLocationBucketViewPathTemplate.match(folderLocationBucketViewName).bucket}matchViewFromFolderLocationBucketViewName(folderLocationBucketViewName){return this.pathTemplates.folderLocationBucketViewPathTemplate.match(folderLocationBucketViewName).view}folderLogPath(folder,log){return this.pathTemplates.folderLogPathTemplate.render({folder:folder,log:log})}matchFolderFromFolderLogName(folderLogName){return this.pathTemplates.folderLogPathTemplate.match(folderLogName).folder}matchLogFromFolderLogName(folderLogName){return this.pathTemplates.folderLogPathTemplate.match(folderLogName).log}folderSinkPath(folder,sink){return this.pathTemplates.folderSinkPathTemplate.render({folder:folder,sink:sink})}matchFolderFromFolderSinkName(folderSinkName){return this.pathTemplates.folderSinkPathTemplate.match(folderSinkName).folder}matchSinkFromFolderSinkName(folderSinkName){return this.pathTemplates.folderSinkPathTemplate.match(folderSinkName).sink}logMetricPath(project,metric){return this.pathTemplates.logMetricPathTemplate.render({project:project,metric:metric})}matchProjectFromLogMetricName(logMetricName){return this.pathTemplates.logMetricPathTemplate.match(logMetricName).project}matchMetricFromLogMetricName(logMetricName){return this.pathTemplates.logMetricPathTemplate.match(logMetricName).metric}organizationCmekSettingsPath(organization){return this.pathTemplates.organizationCmekSettingsPathTemplate.render({organization:organization})}matchOrganizationFromOrganizationCmekSettingsName(organizationCmekSettingsName){return this.pathTemplates.organizationCmekSettingsPathTemplate.match(organizationCmekSettingsName).organization}organizationExclusionPath(organization,exclusion){return this.pathTemplates.organizationExclusionPathTemplate.render({organization:organization,exclusion:exclusion})}matchOrganizationFromOrganizationExclusionName(organizationExclusionName){return this.pathTemplates.organizationExclusionPathTemplate.match(organizationExclusionName).organization}matchExclusionFromOrganizationExclusionName(organizationExclusionName){return this.pathTemplates.organizationExclusionPathTemplate.match(organizationExclusionName).exclusion}organizationLocationBucketPath(organization,location,bucket){return this.pathTemplates.organizationLocationBucketPathTemplate.render({organization:organization,location:location,bucket:bucket})}matchOrganizationFromOrganizationLocationBucketName(organizationLocationBucketName){return this.pathTemplates.organizationLocationBucketPathTemplate.match(organizationLocationBucketName).organization}matchLocationFromOrganizationLocationBucketName(organizationLocationBucketName){return this.pathTemplates.organizationLocationBucketPathTemplate.match(organizationLocationBucketName).location}matchBucketFromOrganizationLocationBucketName(organizationLocationBucketName){return this.pathTemplates.organizationLocationBucketPathTemplate.match(organizationLocationBucketName).bucket}organizationLocationBucketViewPath(organization,location,bucket,view){return this.pathTemplates.organizationLocationBucketViewPathTemplate.render({organization:organization,location:location,bucket:bucket,view:view})}matchOrganizationFromOrganizationLocationBucketViewName(organizationLocationBucketViewName){return this.pathTemplates.organizationLocationBucketViewPathTemplate.match(organizationLocationBucketViewName).organization}matchLocationFromOrganizationLocationBucketViewName(organizationLocationBucketViewName){return this.pathTemplates.organizationLocationBucketViewPathTemplate.match(organizationLocationBucketViewName).location}matchBucketFromOrganizationLocationBucketViewName(organizationLocationBucketViewName){return this.pathTemplates.organizationLocationBucketViewPathTemplate.match(organizationLocationBucketViewName).bucket}matchViewFromOrganizationLocationBucketViewName(organizationLocationBucketViewName){return this.pathTemplates.organizationLocationBucketViewPathTemplate.match(organizationLocationBucketViewName).view}organizationLogPath(organization,log){return this.pathTemplates.organizationLogPathTemplate.render({organization:organization,log:log})}matchOrganizationFromOrganizationLogName(organizationLogName){return this.pathTemplates.organizationLogPathTemplate.match(organizationLogName).organization}matchLogFromOrganizationLogName(organizationLogName){return this.pathTemplates.organizationLogPathTemplate.match(organizationLogName).log}organizationSinkPath(organization,sink){return this.pathTemplates.organizationSinkPathTemplate.render({organization:organization,sink:sink})}matchOrganizationFromOrganizationSinkName(organizationSinkName){return this.pathTemplates.organizationSinkPathTemplate.match(organizationSinkName).organization}matchSinkFromOrganizationSinkName(organizationSinkName){return this.pathTemplates.organizationSinkPathTemplate.match(organizationSinkName).sink}projectPath(project){return this.pathTemplates.projectPathTemplate.render({project:project})}matchProjectFromProjectName(projectName){return this.pathTemplates.projectPathTemplate.match(projectName).project}projectCmekSettingsPath(project){return this.pathTemplates.projectCmekSettingsPathTemplate.render({project:project})}matchProjectFromProjectCmekSettingsName(projectCmekSettingsName){return this.pathTemplates.projectCmekSettingsPathTemplate.match(projectCmekSettingsName).project}projectExclusionPath(project,exclusion){return this.pathTemplates.projectExclusionPathTemplate.render({project:project,exclusion:exclusion})}matchProjectFromProjectExclusionName(projectExclusionName){return this.pathTemplates.projectExclusionPathTemplate.match(projectExclusionName).project}matchExclusionFromProjectExclusionName(projectExclusionName){return this.pathTemplates.projectExclusionPathTemplate.match(projectExclusionName).exclusion}projectLocationBucketPath(project,location,bucket){return this.pathTemplates.projectLocationBucketPathTemplate.render({project:project,location:location,bucket:bucket})}matchProjectFromProjectLocationBucketName(projectLocationBucketName){return this.pathTemplates.projectLocationBucketPathTemplate.match(projectLocationBucketName).project}matchLocationFromProjectLocationBucketName(projectLocationBucketName){return this.pathTemplates.projectLocationBucketPathTemplate.match(projectLocationBucketName).location}matchBucketFromProjectLocationBucketName(projectLocationBucketName){return this.pathTemplates.projectLocationBucketPathTemplate.match(projectLocationBucketName).bucket}projectLocationBucketViewPath(project,location,bucket,view){return this.pathTemplates.projectLocationBucketViewPathTemplate.render({project:project,location:location,bucket:bucket,view:view})}matchProjectFromProjectLocationBucketViewName(projectLocationBucketViewName){return this.pathTemplates.projectLocationBucketViewPathTemplate.match(projectLocationBucketViewName).project}matchLocationFromProjectLocationBucketViewName(projectLocationBucketViewName){return this.pathTemplates.projectLocationBucketViewPathTemplate.match(projectLocationBucketViewName).location}matchBucketFromProjectLocationBucketViewName(projectLocationBucketViewName){return this.pathTemplates.projectLocationBucketViewPathTemplate.match(projectLocationBucketViewName).bucket}matchViewFromProjectLocationBucketViewName(projectLocationBucketViewName){return this.pathTemplates.projectLocationBucketViewPathTemplate.match(projectLocationBucketViewName).view}projectLogPath(project,log){return this.pathTemplates.projectLogPathTemplate.render({project:project,log:log})}matchProjectFromProjectLogName(projectLogName){return this.pathTemplates.projectLogPathTemplate.match(projectLogName).project}matchLogFromProjectLogName(projectLogName){return this.pathTemplates.projectLogPathTemplate.match(projectLogName).log}projectSinkPath(project,sink){return this.pathTemplates.projectSinkPathTemplate.render({project:project,sink:sink})}matchProjectFromProjectSinkName(projectSinkName){return this.pathTemplates.projectSinkPathTemplate.match(projectSinkName).project}matchSinkFromProjectSinkName(projectSinkName){return this.pathTemplates.projectSinkPathTemplate.match(projectSinkName).sink}close(){this.initialize();if(!this._terminated){return this.loggingServiceV2Stub.then(stub=>{this._terminated=true;stub.close()})}return Promise.resolve()}}exports.LoggingServiceV2Client=LoggingServiceV2Client; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.LoggingServiceV2Client=void 0;const gax=require("google-gax");const jsonProtos=require("../../protos/protos.json");const gapicConfig=require("./logging_service_v2_client_config.json");const version=require("../../../package.json").version;class LoggingServiceV2Client{constructor(opts){var _a,_b;this._terminated=false;this.descriptors={page:{},stream:{},longrunning:{},batching:{}};const staticMembers=this.constructor;const servicePath=(opts===null||opts===void 0?void 0:opts.servicePath)||(opts===null||opts===void 0?void 0:opts.apiEndpoint)||staticMembers.servicePath;this._providedCustomServicePath=!!((opts===null||opts===void 0?void 0:opts.servicePath)||(opts===null||opts===void 0?void 0:opts.apiEndpoint));const port=(opts===null||opts===void 0?void 0:opts.port)||staticMembers.port;const clientConfig=(_a=opts===null||opts===void 0?void 0:opts.clientConfig)!==null&&_a!==void 0?_a:{};const fallback=(_b=opts===null||opts===void 0?void 0:opts.fallback)!==null&&_b!==void 0?_b:typeof window!=="undefined"&&typeof(window===null||window===void 0?void 0:window.fetch)==="function";opts=Object.assign({servicePath:servicePath,port:port,clientConfig:clientConfig,fallback:fallback},opts);if(servicePath!==staticMembers.servicePath&&!("scopes"in opts)){opts["scopes"]=staticMembers.scopes}this._gaxModule=opts.fallback?gax.fallback:gax;this._gaxGrpc=new this._gaxModule.GrpcClient(opts);this._opts=opts;this.auth=this._gaxGrpc.auth;this.auth.useJWTAccessWithScope=true;this.auth.defaultServicePath=staticMembers.servicePath;if(servicePath===staticMembers.servicePath){this.auth.defaultScopes=staticMembers.scopes}const clientHeader=[`gax/${this._gaxModule.version}`,`gapic/${version}`];if(typeof process!=="undefined"&&"versions"in process){clientHeader.push(`gl-node/${process.versions.node}`)}else{clientHeader.push(`gl-web/${this._gaxModule.version}`)}if(!opts.fallback){clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`)}else if(opts.fallback==="rest"){clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`)}if(opts.libName&&opts.libVersion){clientHeader.push(`${opts.libName}/${opts.libVersion}`)}this._protos=this._gaxGrpc.loadProtoJSON(jsonProtos);this.pathTemplates={billingAccountCmekSettingsPathTemplate:new this._gaxModule.PathTemplate("billingAccounts/{billing_account}/cmekSettings"),billingAccountExclusionPathTemplate:new this._gaxModule.PathTemplate("billingAccounts/{billing_account}/exclusions/{exclusion}"),billingAccountLocationBucketPathTemplate:new this._gaxModule.PathTemplate("billingAccounts/{billing_account}/locations/{location}/buckets/{bucket}"),billingAccountLocationBucketViewPathTemplate:new this._gaxModule.PathTemplate("billingAccounts/{billing_account}/locations/{location}/buckets/{bucket}/views/{view}"),billingAccountLogPathTemplate:new this._gaxModule.PathTemplate("billingAccounts/{billing_account}/logs/{log}"),billingAccountSinkPathTemplate:new this._gaxModule.PathTemplate("billingAccounts/{billing_account}/sinks/{sink}"),folderCmekSettingsPathTemplate:new this._gaxModule.PathTemplate("folders/{folder}/cmekSettings"),folderExclusionPathTemplate:new this._gaxModule.PathTemplate("folders/{folder}/exclusions/{exclusion}"),folderLocationBucketPathTemplate:new this._gaxModule.PathTemplate("folders/{folder}/locations/{location}/buckets/{bucket}"),folderLocationBucketViewPathTemplate:new this._gaxModule.PathTemplate("folders/{folder}/locations/{location}/buckets/{bucket}/views/{view}"),folderLogPathTemplate:new this._gaxModule.PathTemplate("folders/{folder}/logs/{log}"),folderSinkPathTemplate:new this._gaxModule.PathTemplate("folders/{folder}/sinks/{sink}"),logMetricPathTemplate:new this._gaxModule.PathTemplate("projects/{project}/metrics/{metric}"),organizationCmekSettingsPathTemplate:new this._gaxModule.PathTemplate("organizations/{organization}/cmekSettings"),organizationExclusionPathTemplate:new this._gaxModule.PathTemplate("organizations/{organization}/exclusions/{exclusion}"),organizationLocationBucketPathTemplate:new this._gaxModule.PathTemplate("organizations/{organization}/locations/{location}/buckets/{bucket}"),organizationLocationBucketViewPathTemplate:new this._gaxModule.PathTemplate("organizations/{organization}/locations/{location}/buckets/{bucket}/views/{view}"),organizationLogPathTemplate:new this._gaxModule.PathTemplate("organizations/{organization}/logs/{log}"),organizationSinkPathTemplate:new this._gaxModule.PathTemplate("organizations/{organization}/sinks/{sink}"),projectPathTemplate:new this._gaxModule.PathTemplate("projects/{project}"),projectCmekSettingsPathTemplate:new this._gaxModule.PathTemplate("projects/{project}/cmekSettings"),projectExclusionPathTemplate:new this._gaxModule.PathTemplate("projects/{project}/exclusions/{exclusion}"),projectLocationBucketPathTemplate:new this._gaxModule.PathTemplate("projects/{project}/locations/{location}/buckets/{bucket}"),projectLocationBucketViewPathTemplate:new this._gaxModule.PathTemplate("projects/{project}/locations/{location}/buckets/{bucket}/views/{view}"),projectLogPathTemplate:new this._gaxModule.PathTemplate("projects/{project}/logs/{log}"),projectSinkPathTemplate:new this._gaxModule.PathTemplate("projects/{project}/sinks/{sink}")};this.descriptors.page={listLogEntries:new this._gaxModule.PageDescriptor("pageToken","nextPageToken","entries"),listMonitoredResourceDescriptors:new this._gaxModule.PageDescriptor("pageToken","nextPageToken","resourceDescriptors"),listLogs:new this._gaxModule.PageDescriptor("pageToken","nextPageToken","logNames")};this.descriptors.stream={tailLogEntries:new this._gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING)};const protoFilesRoot=this._gaxModule.protobuf.Root.fromJSON(jsonProtos);this.descriptors.batching={writeLogEntries:new this._gaxModule.BundleDescriptor("entries",["log_name","resource","labels"],null,gax.createByteLengthFunction(protoFilesRoot.lookupType("google.logging.v2.LogEntry")))};this._defaults=this._gaxGrpc.constructSettings("google.logging.v2.LoggingServiceV2",gapicConfig,opts.clientConfig||{},{"x-goog-api-client":clientHeader.join(" ")});this.innerApiCalls={};this.warn=gax.warn}initialize(){var _a;if(this.loggingServiceV2Stub){return this.loggingServiceV2Stub}this.loggingServiceV2Stub=this._gaxGrpc.createStub(this._opts.fallback?this._protos.lookupService("google.logging.v2.LoggingServiceV2"):this._protos.google.logging.v2.LoggingServiceV2,this._opts,this._providedCustomServicePath);const loggingServiceV2StubMethods=["deleteLog","writeLogEntries","listLogEntries","listMonitoredResourceDescriptors","listLogs","tailLogEntries"];for(const methodName of loggingServiceV2StubMethods){const callPromise=this.loggingServiceV2Stub.then(stub=>(...args)=>{if(this._terminated){return Promise.reject("The client has already been closed.")}const func=stub[methodName];return func.apply(stub,args)},err=>()=>{throw err});const descriptor=this.descriptors.page[methodName]||this.descriptors.stream[methodName]||((_a=this.descriptors.batching)===null||_a===void 0?void 0:_a[methodName])||undefined;const apiCall=this._gaxModule.createApiCall(callPromise,this._defaults[methodName],descriptor);this.innerApiCalls[methodName]=apiCall}return this.loggingServiceV2Stub}static get servicePath(){return"logging.googleapis.com"}static get apiEndpoint(){return"logging.googleapis.com"}static get port(){return 443}static get scopes(){return["https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloud-platform.read-only","https://www.googleapis.com/auth/logging.admin","https://www.googleapis.com/auth/logging.read","https://www.googleapis.com/auth/logging.write"]}getProjectId(callback){if(callback){this.auth.getProjectId(callback);return}return this.auth.getProjectId()}deleteLog(request,optionsOrCallback,callback){request=request||{};let options;if(typeof optionsOrCallback==="function"&&callback===undefined){callback=optionsOrCallback;options={}}else{options=optionsOrCallback}options=options||{};options.otherArgs=options.otherArgs||{};options.otherArgs.headers=options.otherArgs.headers||{};options.otherArgs.headers["x-goog-request-params"]=gax.routingHeader.fromParams({log_name:request.logName||""});this.initialize();return this.innerApiCalls.deleteLog(request,options,callback)}writeLogEntries(request,optionsOrCallback,callback){request=request||{};let options;if(typeof optionsOrCallback==="function"&&callback===undefined){callback=optionsOrCallback;options={}}else{options=optionsOrCallback}options=options||{};options.otherArgs=options.otherArgs||{};options.otherArgs.headers=options.otherArgs.headers||{};this.initialize();return this.innerApiCalls.writeLogEntries(request,options,callback)}tailLogEntries(options){this.initialize();return this.innerApiCalls.tailLogEntries(null,options)}listLogEntries(request,optionsOrCallback,callback){request=request||{};let options;if(typeof optionsOrCallback==="function"&&callback===undefined){callback=optionsOrCallback;options={}}else{options=optionsOrCallback}options=options||{};options.otherArgs=options.otherArgs||{};options.otherArgs.headers=options.otherArgs.headers||{};this.initialize();return this.innerApiCalls.listLogEntries(request,options,callback)}listLogEntriesStream(request,options){request=request||{};options=options||{};options.otherArgs=options.otherArgs||{};options.otherArgs.headers=options.otherArgs.headers||{};const defaultCallSettings=this._defaults["listLogEntries"];const callSettings=defaultCallSettings.merge(options);this.initialize();return this.descriptors.page.listLogEntries.createStream(this.innerApiCalls.listLogEntries,request,callSettings)}listLogEntriesAsync(request,options){request=request||{};options=options||{};options.otherArgs=options.otherArgs||{};options.otherArgs.headers=options.otherArgs.headers||{};const defaultCallSettings=this._defaults["listLogEntries"];const callSettings=defaultCallSettings.merge(options);this.initialize();return this.descriptors.page.listLogEntries.asyncIterate(this.innerApiCalls["listLogEntries"],request,callSettings)}listMonitoredResourceDescriptors(request,optionsOrCallback,callback){request=request||{};let options;if(typeof optionsOrCallback==="function"&&callback===undefined){callback=optionsOrCallback;options={}}else{options=optionsOrCallback}options=options||{};options.otherArgs=options.otherArgs||{};options.otherArgs.headers=options.otherArgs.headers||{};this.initialize();return this.innerApiCalls.listMonitoredResourceDescriptors(request,options,callback)}listMonitoredResourceDescriptorsStream(request,options){request=request||{};options=options||{};options.otherArgs=options.otherArgs||{};options.otherArgs.headers=options.otherArgs.headers||{};const defaultCallSettings=this._defaults["listMonitoredResourceDescriptors"];const callSettings=defaultCallSettings.merge(options);this.initialize();return this.descriptors.page.listMonitoredResourceDescriptors.createStream(this.innerApiCalls.listMonitoredResourceDescriptors,request,callSettings)}listMonitoredResourceDescriptorsAsync(request,options){request=request||{};options=options||{};options.otherArgs=options.otherArgs||{};options.otherArgs.headers=options.otherArgs.headers||{};const defaultCallSettings=this._defaults["listMonitoredResourceDescriptors"];const callSettings=defaultCallSettings.merge(options);this.initialize();return this.descriptors.page.listMonitoredResourceDescriptors.asyncIterate(this.innerApiCalls["listMonitoredResourceDescriptors"],request,callSettings)}listLogs(request,optionsOrCallback,callback){request=request||{};let options;if(typeof optionsOrCallback==="function"&&callback===undefined){callback=optionsOrCallback;options={}}else{options=optionsOrCallback}options=options||{};options.otherArgs=options.otherArgs||{};options.otherArgs.headers=options.otherArgs.headers||{};options.otherArgs.headers["x-goog-request-params"]=gax.routingHeader.fromParams({parent:request.parent||""});this.initialize();return this.innerApiCalls.listLogs(request,options,callback)}listLogsStream(request,options){request=request||{};options=options||{};options.otherArgs=options.otherArgs||{};options.otherArgs.headers=options.otherArgs.headers||{};options.otherArgs.headers["x-goog-request-params"]=gax.routingHeader.fromParams({parent:request.parent||""});const defaultCallSettings=this._defaults["listLogs"];const callSettings=defaultCallSettings.merge(options);this.initialize();return this.descriptors.page.listLogs.createStream(this.innerApiCalls.listLogs,request,callSettings)}listLogsAsync(request,options){request=request||{};options=options||{};options.otherArgs=options.otherArgs||{};options.otherArgs.headers=options.otherArgs.headers||{};options.otherArgs.headers["x-goog-request-params"]=gax.routingHeader.fromParams({parent:request.parent||""});const defaultCallSettings=this._defaults["listLogs"];const callSettings=defaultCallSettings.merge(options);this.initialize();return this.descriptors.page.listLogs.asyncIterate(this.innerApiCalls["listLogs"],request,callSettings)}billingAccountCmekSettingsPath(billingAccount){return this.pathTemplates.billingAccountCmekSettingsPathTemplate.render({billing_account:billingAccount})}matchBillingAccountFromBillingAccountCmekSettingsName(billingAccountCmekSettingsName){return this.pathTemplates.billingAccountCmekSettingsPathTemplate.match(billingAccountCmekSettingsName).billing_account}billingAccountExclusionPath(billingAccount,exclusion){return this.pathTemplates.billingAccountExclusionPathTemplate.render({billing_account:billingAccount,exclusion:exclusion})}matchBillingAccountFromBillingAccountExclusionName(billingAccountExclusionName){return this.pathTemplates.billingAccountExclusionPathTemplate.match(billingAccountExclusionName).billing_account}matchExclusionFromBillingAccountExclusionName(billingAccountExclusionName){return this.pathTemplates.billingAccountExclusionPathTemplate.match(billingAccountExclusionName).exclusion}billingAccountLocationBucketPath(billingAccount,location,bucket){return this.pathTemplates.billingAccountLocationBucketPathTemplate.render({billing_account:billingAccount,location:location,bucket:bucket})}matchBillingAccountFromBillingAccountLocationBucketName(billingAccountLocationBucketName){return this.pathTemplates.billingAccountLocationBucketPathTemplate.match(billingAccountLocationBucketName).billing_account}matchLocationFromBillingAccountLocationBucketName(billingAccountLocationBucketName){return this.pathTemplates.billingAccountLocationBucketPathTemplate.match(billingAccountLocationBucketName).location}matchBucketFromBillingAccountLocationBucketName(billingAccountLocationBucketName){return this.pathTemplates.billingAccountLocationBucketPathTemplate.match(billingAccountLocationBucketName).bucket}billingAccountLocationBucketViewPath(billingAccount,location,bucket,view){return this.pathTemplates.billingAccountLocationBucketViewPathTemplate.render({billing_account:billingAccount,location:location,bucket:bucket,view:view})}matchBillingAccountFromBillingAccountLocationBucketViewName(billingAccountLocationBucketViewName){return this.pathTemplates.billingAccountLocationBucketViewPathTemplate.match(billingAccountLocationBucketViewName).billing_account}matchLocationFromBillingAccountLocationBucketViewName(billingAccountLocationBucketViewName){return this.pathTemplates.billingAccountLocationBucketViewPathTemplate.match(billingAccountLocationBucketViewName).location}matchBucketFromBillingAccountLocationBucketViewName(billingAccountLocationBucketViewName){return this.pathTemplates.billingAccountLocationBucketViewPathTemplate.match(billingAccountLocationBucketViewName).bucket}matchViewFromBillingAccountLocationBucketViewName(billingAccountLocationBucketViewName){return this.pathTemplates.billingAccountLocationBucketViewPathTemplate.match(billingAccountLocationBucketViewName).view}billingAccountLogPath(billingAccount,log){return this.pathTemplates.billingAccountLogPathTemplate.render({billing_account:billingAccount,log:log})}matchBillingAccountFromBillingAccountLogName(billingAccountLogName){return this.pathTemplates.billingAccountLogPathTemplate.match(billingAccountLogName).billing_account}matchLogFromBillingAccountLogName(billingAccountLogName){return this.pathTemplates.billingAccountLogPathTemplate.match(billingAccountLogName).log}billingAccountSinkPath(billingAccount,sink){return this.pathTemplates.billingAccountSinkPathTemplate.render({billing_account:billingAccount,sink:sink})}matchBillingAccountFromBillingAccountSinkName(billingAccountSinkName){return this.pathTemplates.billingAccountSinkPathTemplate.match(billingAccountSinkName).billing_account}matchSinkFromBillingAccountSinkName(billingAccountSinkName){return this.pathTemplates.billingAccountSinkPathTemplate.match(billingAccountSinkName).sink}folderCmekSettingsPath(folder){return this.pathTemplates.folderCmekSettingsPathTemplate.render({folder:folder})}matchFolderFromFolderCmekSettingsName(folderCmekSettingsName){return this.pathTemplates.folderCmekSettingsPathTemplate.match(folderCmekSettingsName).folder}folderExclusionPath(folder,exclusion){return this.pathTemplates.folderExclusionPathTemplate.render({folder:folder,exclusion:exclusion})}matchFolderFromFolderExclusionName(folderExclusionName){return this.pathTemplates.folderExclusionPathTemplate.match(folderExclusionName).folder}matchExclusionFromFolderExclusionName(folderExclusionName){return this.pathTemplates.folderExclusionPathTemplate.match(folderExclusionName).exclusion}folderLocationBucketPath(folder,location,bucket){return this.pathTemplates.folderLocationBucketPathTemplate.render({folder:folder,location:location,bucket:bucket})}matchFolderFromFolderLocationBucketName(folderLocationBucketName){return this.pathTemplates.folderLocationBucketPathTemplate.match(folderLocationBucketName).folder}matchLocationFromFolderLocationBucketName(folderLocationBucketName){return this.pathTemplates.folderLocationBucketPathTemplate.match(folderLocationBucketName).location}matchBucketFromFolderLocationBucketName(folderLocationBucketName){return this.pathTemplates.folderLocationBucketPathTemplate.match(folderLocationBucketName).bucket}folderLocationBucketViewPath(folder,location,bucket,view){return this.pathTemplates.folderLocationBucketViewPathTemplate.render({folder:folder,location:location,bucket:bucket,view:view})}matchFolderFromFolderLocationBucketViewName(folderLocationBucketViewName){return this.pathTemplates.folderLocationBucketViewPathTemplate.match(folderLocationBucketViewName).folder}matchLocationFromFolderLocationBucketViewName(folderLocationBucketViewName){return this.pathTemplates.folderLocationBucketViewPathTemplate.match(folderLocationBucketViewName).location}matchBucketFromFolderLocationBucketViewName(folderLocationBucketViewName){return this.pathTemplates.folderLocationBucketViewPathTemplate.match(folderLocationBucketViewName).bucket}matchViewFromFolderLocationBucketViewName(folderLocationBucketViewName){return this.pathTemplates.folderLocationBucketViewPathTemplate.match(folderLocationBucketViewName).view}folderLogPath(folder,log){return this.pathTemplates.folderLogPathTemplate.render({folder:folder,log:log})}matchFolderFromFolderLogName(folderLogName){return this.pathTemplates.folderLogPathTemplate.match(folderLogName).folder}matchLogFromFolderLogName(folderLogName){return this.pathTemplates.folderLogPathTemplate.match(folderLogName).log}folderSinkPath(folder,sink){return this.pathTemplates.folderSinkPathTemplate.render({folder:folder,sink:sink})}matchFolderFromFolderSinkName(folderSinkName){return this.pathTemplates.folderSinkPathTemplate.match(folderSinkName).folder}matchSinkFromFolderSinkName(folderSinkName){return this.pathTemplates.folderSinkPathTemplate.match(folderSinkName).sink}logMetricPath(project,metric){return this.pathTemplates.logMetricPathTemplate.render({project:project,metric:metric})}matchProjectFromLogMetricName(logMetricName){return this.pathTemplates.logMetricPathTemplate.match(logMetricName).project}matchMetricFromLogMetricName(logMetricName){return this.pathTemplates.logMetricPathTemplate.match(logMetricName).metric}organizationCmekSettingsPath(organization){return this.pathTemplates.organizationCmekSettingsPathTemplate.render({organization:organization})}matchOrganizationFromOrganizationCmekSettingsName(organizationCmekSettingsName){return this.pathTemplates.organizationCmekSettingsPathTemplate.match(organizationCmekSettingsName).organization}organizationExclusionPath(organization,exclusion){return this.pathTemplates.organizationExclusionPathTemplate.render({organization:organization,exclusion:exclusion})}matchOrganizationFromOrganizationExclusionName(organizationExclusionName){return this.pathTemplates.organizationExclusionPathTemplate.match(organizationExclusionName).organization}matchExclusionFromOrganizationExclusionName(organizationExclusionName){return this.pathTemplates.organizationExclusionPathTemplate.match(organizationExclusionName).exclusion}organizationLocationBucketPath(organization,location,bucket){return this.pathTemplates.organizationLocationBucketPathTemplate.render({organization:organization,location:location,bucket:bucket})}matchOrganizationFromOrganizationLocationBucketName(organizationLocationBucketName){return this.pathTemplates.organizationLocationBucketPathTemplate.match(organizationLocationBucketName).organization}matchLocationFromOrganizationLocationBucketName(organizationLocationBucketName){return this.pathTemplates.organizationLocationBucketPathTemplate.match(organizationLocationBucketName).location}matchBucketFromOrganizationLocationBucketName(organizationLocationBucketName){return this.pathTemplates.organizationLocationBucketPathTemplate.match(organizationLocationBucketName).bucket}organizationLocationBucketViewPath(organization,location,bucket,view){return this.pathTemplates.organizationLocationBucketViewPathTemplate.render({organization:organization,location:location,bucket:bucket,view:view})}matchOrganizationFromOrganizationLocationBucketViewName(organizationLocationBucketViewName){return this.pathTemplates.organizationLocationBucketViewPathTemplate.match(organizationLocationBucketViewName).organization}matchLocationFromOrganizationLocationBucketViewName(organizationLocationBucketViewName){return this.pathTemplates.organizationLocationBucketViewPathTemplate.match(organizationLocationBucketViewName).location}matchBucketFromOrganizationLocationBucketViewName(organizationLocationBucketViewName){return this.pathTemplates.organizationLocationBucketViewPathTemplate.match(organizationLocationBucketViewName).bucket}matchViewFromOrganizationLocationBucketViewName(organizationLocationBucketViewName){return this.pathTemplates.organizationLocationBucketViewPathTemplate.match(organizationLocationBucketViewName).view}organizationLogPath(organization,log){return this.pathTemplates.organizationLogPathTemplate.render({organization:organization,log:log})}matchOrganizationFromOrganizationLogName(organizationLogName){return this.pathTemplates.organizationLogPathTemplate.match(organizationLogName).organization}matchLogFromOrganizationLogName(organizationLogName){return this.pathTemplates.organizationLogPathTemplate.match(organizationLogName).log}organizationSinkPath(organization,sink){return this.pathTemplates.organizationSinkPathTemplate.render({organization:organization,sink:sink})}matchOrganizationFromOrganizationSinkName(organizationSinkName){return this.pathTemplates.organizationSinkPathTemplate.match(organizationSinkName).organization}matchSinkFromOrganizationSinkName(organizationSinkName){return this.pathTemplates.organizationSinkPathTemplate.match(organizationSinkName).sink}projectPath(project){return this.pathTemplates.projectPathTemplate.render({project:project})}matchProjectFromProjectName(projectName){return this.pathTemplates.projectPathTemplate.match(projectName).project}projectCmekSettingsPath(project){return this.pathTemplates.projectCmekSettingsPathTemplate.render({project:project})}matchProjectFromProjectCmekSettingsName(projectCmekSettingsName){return this.pathTemplates.projectCmekSettingsPathTemplate.match(projectCmekSettingsName).project}projectExclusionPath(project,exclusion){return this.pathTemplates.projectExclusionPathTemplate.render({project:project,exclusion:exclusion})}matchProjectFromProjectExclusionName(projectExclusionName){return this.pathTemplates.projectExclusionPathTemplate.match(projectExclusionName).project}matchExclusionFromProjectExclusionName(projectExclusionName){return this.pathTemplates.projectExclusionPathTemplate.match(projectExclusionName).exclusion}projectLocationBucketPath(project,location,bucket){return this.pathTemplates.projectLocationBucketPathTemplate.render({project:project,location:location,bucket:bucket})}matchProjectFromProjectLocationBucketName(projectLocationBucketName){return this.pathTemplates.projectLocationBucketPathTemplate.match(projectLocationBucketName).project}matchLocationFromProjectLocationBucketName(projectLocationBucketName){return this.pathTemplates.projectLocationBucketPathTemplate.match(projectLocationBucketName).location}matchBucketFromProjectLocationBucketName(projectLocationBucketName){return this.pathTemplates.projectLocationBucketPathTemplate.match(projectLocationBucketName).bucket}projectLocationBucketViewPath(project,location,bucket,view){return this.pathTemplates.projectLocationBucketViewPathTemplate.render({project:project,location:location,bucket:bucket,view:view})}matchProjectFromProjectLocationBucketViewName(projectLocationBucketViewName){return this.pathTemplates.projectLocationBucketViewPathTemplate.match(projectLocationBucketViewName).project}matchLocationFromProjectLocationBucketViewName(projectLocationBucketViewName){return this.pathTemplates.projectLocationBucketViewPathTemplate.match(projectLocationBucketViewName).location}matchBucketFromProjectLocationBucketViewName(projectLocationBucketViewName){return this.pathTemplates.projectLocationBucketViewPathTemplate.match(projectLocationBucketViewName).bucket}matchViewFromProjectLocationBucketViewName(projectLocationBucketViewName){return this.pathTemplates.projectLocationBucketViewPathTemplate.match(projectLocationBucketViewName).view}projectLogPath(project,log){return this.pathTemplates.projectLogPathTemplate.render({project:project,log:log})}matchProjectFromProjectLogName(projectLogName){return this.pathTemplates.projectLogPathTemplate.match(projectLogName).project}matchLogFromProjectLogName(projectLogName){return this.pathTemplates.projectLogPathTemplate.match(projectLogName).log}projectSinkPath(project,sink){return this.pathTemplates.projectSinkPathTemplate.render({project:project,sink:sink})}matchProjectFromProjectSinkName(projectSinkName){return this.pathTemplates.projectSinkPathTemplate.match(projectSinkName).project}matchSinkFromProjectSinkName(projectSinkName){return this.pathTemplates.projectSinkPathTemplate.match(projectSinkName).sink}close(){this.initialize();if(!this._terminated){return this.loggingServiceV2Stub.then(stub=>{this._terminated=true;stub.close()})}return Promise.resolve()}}exports.LoggingServiceV2Client=LoggingServiceV2Client; | ||
//# sourceMappingURL=logging_service_v2_client.js.map |
@@ -8,2 +8,9 @@ # Changelog | ||
### [9.6.9](https://github.com/googleapis/nodejs-logging/compare/v9.6.8...v9.6.9) (2022-02-09) | ||
### Bug Fixes | ||
* Regular error showing Total timeout of API google.logging.v2.LoggingServiceV2 exceeded 600000 milliseconds ([#1225](https://github.com/googleapis/nodejs-logging/issues/1225)) ([7f584bc](https://github.com/googleapis/nodejs-logging/commit/7f584bc307ed18e333002177436046b3c30f4aa0)) | ||
### [9.6.8](https://github.com/googleapis/nodejs-logging/compare/v9.6.7...v9.6.8) (2022-01-21) | ||
@@ -10,0 +17,0 @@ |
{ | ||
"name": "@google-cloud/logging-min", | ||
"version": "9.6.8", | ||
"version": "9.6.9", | ||
"description": "Stackdriver Logging Client Library for Node.js", | ||
@@ -90,3 +90,3 @@ "keywords": [ | ||
"proxyquire": "^2.1.3", | ||
"sinon": "^12.0.0", | ||
"sinon": "^13.0.0", | ||
"ts-loader": "^9.0.0", | ||
@@ -93,0 +93,0 @@ "typescript": "^3.8.3", |
@@ -165,3 +165,58 @@ [//]: # "This README.md file is auto-generated, all changes to this file will be lost." | ||
## Error handling with logs written or deleted asynchronously | ||
The `Log` class provide users the ability to write and delete logs asynchronously. However, there are cases when log entries | ||
cannot be written or deleted and error is thrown - if error is not handled properly, it could crash the application. | ||
One possible way to catch the error is to `await` the log write/delete calls and wrap it with `try/catch` like in example below: | ||
```js | ||
// Write log entry and and catch any errors | ||
try { | ||
await log.write(entry); | ||
} catch (err) { | ||
console.log('Error is: ' + err); | ||
} | ||
``` | ||
However, awaiting for every `log.write` or `log.delete` calls may introduce delays which could be avoided by | ||
simply adding a callback like in the example below. This way the log entry can be queued for processing and code | ||
execution will continue without further delays. The callback will be called once the operation is complete: | ||
```js | ||
// Asynchronously write the log entry and handle respone or any errors in provided callback | ||
log.write(entry, err => { | ||
if (err) { | ||
// The log entry was not written. | ||
console.log(err.message); | ||
} else { | ||
console.log('No error in write callback!'); | ||
} | ||
}); | ||
``` | ||
Adding a callback to every `log.write` or `log.delete` calls could be a burden, especially if code | ||
handling the error is always the same. For this purpose we introduced an ability to provide a default callback | ||
for `Log` class which could be set through `LogOptions` passed to `Log` constructor as in example below - this | ||
way you can define a global callback once for all `log.write` and `log.delete` calls and be able to handle errors: | ||
```js | ||
const {Logging} = require('@google-cloud/logging'); | ||
const logging = new Logging(); | ||
// Create options with default callback to be called on every write/delete response or error | ||
const options = { | ||
defaultWriteDeleteCallback: function (err) { | ||
if (err) { | ||
console.log('Error is: ' + err); | ||
} else { | ||
console.log('No error, all is good!'); | ||
} | ||
}, | ||
}; | ||
const log = logging.log('my-log', options); | ||
``` | ||
See the full sample in `writeLogWithCallback` function [here](https://github.com/googleapis/nodejs-logging/blob/master/samples/logs.js). | ||
## Samples | ||
@@ -189,18 +244,18 @@ | ||
Node.js. | ||
If you are using an end-of-life version of Node.js, we recommend that you update | ||
as soon as possible to an actively supported LTS version. | ||
Google's client libraries support legacy versions of Node.js runtimes on a | ||
best-efforts basis with the following warnings: | ||
* Legacy versions are not tested in continuous integration. | ||
* Some security patches and features cannot be backported. | ||
* Dependencies cannot be kept up-to-date. | ||
Client libraries targeting some end-of-life versions of Node.js are available, and | ||
can be installed via npm [dist-tags](https://docs.npmjs.com/cli/dist-tag). | ||
can be installed through npm [dist-tags](https://docs.npmjs.com/cli/dist-tag). | ||
The dist-tags follow the naming convention `legacy-(version)`. | ||
For example, `npm install @google-cloud/logging@legacy-8` installs client libraries | ||
for versions compatible with Node.js 8. | ||
_Legacy Node.js versions are supported as a best effort:_ | ||
* Legacy versions will not be tested in continuous integration. | ||
* Some security patches may not be able to be backported. | ||
* Dependencies will not be kept up-to-date, and features will not be backported. | ||
#### Legacy tags available | ||
* `legacy-8`: install client libraries from this dist-tag for versions | ||
compatible with Node.js 8. | ||
## Versioning | ||
@@ -207,0 +262,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2080022
22702
302