UNPKG

31.1 kBTypeScriptView Raw
1/*!
2 * Copyright 2015 Google Inc. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import * as gax from 'google-gax';
17import * as middleware from './middleware';
18import { detectServiceContext } from './utils/metadata';
19import { CloudLoggingHttpRequest as HttpRequest } from './utils/http-request';
20export { middleware };
21export { HttpRequest };
22export { detectServiceContext };
23declare const v2: any;
24import { Entry, LogEntry } from './entry';
25import { MonitoredResource, Severity, SeverityNames, formatLogName, assignSeverityToEntries } from './utils/log-common';
26import { Log, GetEntriesRequest, TailEntriesRequest, LogOptions } from './log';
27import { LogSync, LogSyncOptions } from './log-sync';
28import { Sink } from './sink';
29import { Duplex, Writable } from 'stream';
30import { google } from '../protos/protos';
31export interface LoggingOptions extends gax.GrpcClientOptions {
32 autoRetry?: boolean;
33 maxRetries?: number;
34 apiEndpoint?: string;
35}
36export interface DeleteCallback {
37 (error?: Error | null, response?: google.protobuf.Empty): void;
38}
39export type DeleteResponse = google.protobuf.Empty;
40export type LogSink = google.logging.v2.ILogSink;
41export interface AbortableDuplex extends Duplex {
42 abort(): void;
43}
44export interface CreateSinkRequest {
45 destination: any;
46 filter?: string;
47 includeChildren?: boolean;
48 name?: string;
49 outputVersionFormat?: google.logging.v2.LogSink.VersionFormat;
50 uniqueWriterIdentity?: string | boolean;
51 gaxOptions?: gax.CallOptions;
52}
53export interface CreateSinkCallback {
54 (err: Error | null, sink?: Sink | null, resp?: LogSink): void;
55}
56export type GetEntriesResponse = [
57 Entry[],
58 google.logging.v2.IListLogEntriesRequest,
59 google.logging.v2.IListLogEntriesResponse
60];
61export interface GetEntriesCallback {
62 (err: Error | null, entries?: Entry[], request?: google.logging.v2.IListLogEntriesRequest, apiResponse?: google.logging.v2.IListLogEntriesResponse): void;
63}
64export interface TailEntriesResponse {
65 entries: Entry[];
66 suppressionInfo: google.logging.v2.TailLogEntriesResponse.SuppressionInfo;
67}
68export interface GetLogsRequest {
69 autoPaginate?: boolean;
70 gaxOptions?: gax.CallOptions;
71 maxApiCalls?: number;
72 maxResults?: number;
73 pageSize?: number;
74 pageToken?: string;
75}
76export type GetLogsResponse = [
77 Sink[],
78 google.logging.v2.IListLogsRequest,
79 google.logging.v2.IListLogsResponse
80];
81export interface GetLogsCallback {
82 (err: Error | null, entries?: Sink[], request?: google.logging.v2.IListLogsRequest, apiResponse?: google.logging.v2.IListLogsResponse): void;
83}
84export interface GetSinksRequest {
85 autoPaginate?: boolean;
86 gaxOptions?: gax.CallOptions;
87 maxApiCalls?: number;
88 maxResults?: number;
89 pageSize?: number;
90 pageToken?: string;
91}
92export type GetSinksResponse = [
93 Sink[],
94 google.logging.v2.IListSinksRequest,
95 google.logging.v2.IListSinksResponse
96];
97export interface GetSinksCallback {
98 (err: Error | null, entries?: Sink[], request?: google.logging.v2.IListSinksRequest, apiResponse?: google.logging.v2.IListSinksResponse): void;
99}
100export type Client = string;
101export interface RequestConfig {
102 client: Client;
103 method: string;
104 reqOpts?: object;
105 gaxOpts?: gax.CallOptions;
106}
107export interface RequestCallback<TResponse> {
108 (err: Error | null, res?: TResponse): void;
109}
110/**
111 * For logged errors, one can provide a the service context. For more
112 * information see [this guide]{@link
113 * https://cloud.google.com/error-reporting/docs/formatting-error-messages}
114 * and the [official documentation]{@link
115 * https://cloud.google.com/error-reporting/reference/rest/v1beta1/ServiceContext}.
116 */
117export interface ServiceContext {
118 /**
119 * An identifier of the service, such as the name of the executable, job, or
120 * Google App Engine service name.
121 */
122 service?: string;
123 /**
124 * Represents the version of the service.
125 */
126 version?: string;
127}
128/**
129 * @typedef {object} ClientConfig
130 * @property {string} [projectId] The project ID from the Google Developer's
131 * Console, e.g. 'grape-spaceship-123'. We will also check the environment
132 * variable `GCLOUD_PROJECT` for your project ID. If your app is running in
133 * an environment which supports {@link
134 * https://cloud.google.com/docs/authentication/production#providing_credentials_to_your_application
135 * Application Default Credentials}, your project ID will be detected
136 * automatically.
137 * @property {string} [keyFilename] Full path to the a .json, .pem, or .p12 key
138 * downloaded from the Google Developers Console. If you provide a path to a
139 * JSON file, the `projectId` option above is not necessary. NOTE: .pem and
140 * .p12 require you to specify the `email` option as well.
141 * @property {string} [email] Account email address. Required when using a .pem
142 * or .p12 keyFilename.
143 * @property {object} [credentials] Credentials object.
144 * @property {string} [credentials.client_email]
145 * @property {string} [credentials.private_key]
146 * @property {boolean} [autoRetry=true] Automatically retry requests if the
147 * response is related to rate limits or certain intermittent server errors.
148 * We will exponentially backoff subsequent requests by default.
149 * @property {number} [maxRetries=3] Maximum number of automatic retries
150 * attempted before returning the error.
151 * @property {Constructor} [promise] Custom promise module to use instead of
152 * native Promises.
153 */
154/**
155 * {@link https://cloud.google.com/logging/docs| Cloud Logging} allows you to
156 * store, search, analyze, monitor, and alert on log data and events from Google
157 * Cloud Platform and Amazon Web Services (AWS).
158 *
159 * @class
160 *
161 * See {@link https://cloud.google.com/logging/docs| What is Cloud Logging?}
162 *
163 * See {@link https://cloud.google.com/logging/docs/api| Introduction to the Cloud Logging API}
164 *
165 * See {@link https://www.npmjs.com/package/@google-cloud/logging-bunyan| Logging to Google Cloud from Bunyan}
166 *
167 * See {@link https://www.npmjs.com/package/@google-cloud/logging-winston| Logging to Google Cloud from Winston}
168 *
169 * @param {ClientConfig} [options] Configuration options.
170 *
171 * @example Import the client library
172 * ```
173 * const {Logging} = require('@google-cloud/logging');
174 *
175 * ```
176 * @example Create a client that uses <a href="https://cloud.google.com/docs/authentication/production#providing_credentials_to_your_application">Application Default Credentials (ADC)</a>:
177 * ```
178 * const logging = new Logging();
179 *
180 * ```
181 * @example Create a client with <a href="https://cloud.google.com/docs/authentication/production#obtaining_and_providing_service_account_credentials_manually">explicitcredentials</a>:
182 * ```
183 * const logging = new Logging({ projectId:
184 * 'your-project-id', keyFilename: '/path/to/keyfile.json'
185 * });
186 *
187 * ```
188 * @example <caption>include:samples/quickstart.js</caption>
189 * region_tag:logging_quickstart
190 * Full quickstart example:
191 */
192declare class Logging {
193 api: {
194 [key: string]: gax.ClientStub;
195 };
196 auth: gax.GoogleAuth;
197 options: LoggingOptions;
198 projectId: string;
199 detectedResource?: object;
200 configService?: typeof v2.ConfigServiceV2Client;
201 loggingService?: typeof v2.LoggingServiceV2Client;
202 constructor(options?: LoggingOptions, gaxInstance?: typeof gax);
203 /**
204 * Config to set for the sink. Not all available options are listed here, see
205 * the [Sink
206 * resource](https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks#LogSink)
207 * definition for full details.
208 *
209 * @typedef {object} CreateSinkRequest
210 * @property {object} [gaxOptions] Request configuration options, outlined
211 * here: https://googleapis.github.io/gax-nodejs/global.html#CallOptions.
212 * @property {Bucket|Dataset|Topic} [destination] The destination. The proper ACL
213 * scopes will be granted to the provided destination. Can be one of:
214 * {@link https://googleapis.dev/nodejs/storage/latest/ Bucket},
215 * {@link https://googleapis.dev/nodejs/bigquery/latest/ Dataset}, or
216 * {@link https://googleapis.dev/nodejs/pubsub/latest/ Topic}
217 * @property {string} [filter] An advanced logs filter. Only log entries
218 * matching the filter are written.
219 * @property {string|boolean} [uniqueWriterIdentity] Determines the kind of IAM
220 * identity returned as `writerIdentity` in the new sink. See {@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/create#query-parameters}.
221 */
222 /**
223 * @typedef {array} CreateSinkResponse
224 * @property {Sink} 0 The new {@link Sink}.
225 * @property {object} 1 The full API response.
226 */
227 /**
228 * @callback CreateSinkCallback
229 * @param {?Error} err Request error, if any.
230 * @param {Sink} sink The new {@link Sink}.
231 * @param {object} apiResponse The full API response.
232 */
233 createSink(name: string, config: CreateSinkRequest): Promise<[Sink, LogSink]>;
234 createSink(name: string, config: CreateSinkRequest, callback: CreateSinkCallback): void;
235 /**
236 * Create an entry object.
237 *
238 * Using this method will not itself make any API requests. You will use
239 * the object returned in other API calls, such as
240 * {@link Log#write}.
241 *
242 * Note, {@link https://cloud.google.com/logging/quotas|Cloud Logging Quotas and limits}
243 * dictates that the maximum log entry size, including all
244 * [LogEntry Resource properties]{@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry},
245 * cannot exceed _approximately_ 256 KB.
246 *
247 * See {@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry|LogEntry JSON representation}
248 *
249 * @param {?object|?string} [resource] See a
250 * [Monitored
251 * Resource](https://cloud.google.com/logging/docs/reference/v2/rest/v2/MonitoredResource).
252 * @param {object|string} data The data to use as the value for this log
253 * entry.
254 * @returns {Entry}
255 *
256 * @example
257 * ```
258 * const {Logging} = require('@google-cloud/logging');
259 * const logging = new Logging();
260 *
261 * const resource = {
262 * type: 'gce_instance',
263 * labels: {
264 * zone: 'global',
265 * instance_id: '3'
266 * }
267 * };
268 *
269 * const entry = logging.entry(resource, {
270 * delegate: 'my_username'
271 * });
272 *
273 * entry.toJSON();
274 * // {
275 * // resource: {
276 * // type: 'gce_instance',
277 * // labels: {
278 * // zone: 'global',
279 * // instance_id: '3'
280 * // }
281 * // },
282 * // jsonPayload: {
283 * // delegate: 'my_username'
284 * // }
285 * // }
286 * ```
287 */
288 entry(resource?: LogEntry, data?: {} | string): Entry;
289 /**
290 * Query object for listing entries.
291 *
292 * @typedef {object} GetEntriesRequest
293 * @property {boolean} [autoPaginate=true] Have pagination handled
294 * automatically.
295 * @property {string} [filter] An
296 * [advanced logs
297 * filter](https://cloud.google.com/logging/docs/view/advanced_filters). An
298 * empty filter matches all log entries.
299 * @property {object} [gaxOptions] Request configuration options, outlined
300 * here: https://googleapis.github.io/gax-nodejs/global.html#CallOptions.
301 * @property {string} [log] A name of the log specifying to pnly return
302 * entries from this log.
303 * @property {number} [maxApiCalls] Maximum number of API calls to make.
304 * @property {number} [maxResults] Maximum number of items plus prefixes to
305 * return.
306 * @property {string} [orderBy] How the results should be sorted,
307 * `timestamp asc` (oldest first) and `timestamp desc` (newest first,
308 * **default**).
309 * @property {number} [pageSize] Maximum number of logs to return.
310 * @property {string} [pageToken] A previously-returned page token
311 * representing part of the larger set of results to view.
312 */
313 /**
314 * @typedef {array} GetEntriesResponse
315 * @property {Entry[]} 0 Array of {@link Entry} instances.
316 * @property {object} 1 The full API request.
317 * @property {object} 2 The full API response.
318 */
319 /**
320 * @callback GetEntriesCallback
321 * @param {?Error} err Request error, if any.
322 * @param {Entry[]} entries Array of {@link Entry} instances.
323 * @param {object} apiResponse The full API response.
324 */
325 /**
326 * List the entries in your logs.
327 *
328 * See {@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries/list|entries.list API Documentation}
329 *
330 * @param {GetEntriesRequest} [query] Query object for listing entries.
331 * @param {GetEntriesCallback} [callback] Callback function.
332 * @returns {Promise<GetEntriesResponse>}
333 *
334 * @example
335 * ```
336 * const {Logging} = require('@google-cloud/logging');
337 * const logging = new Logging();
338 *
339 * logging.getEntries((err, entries) => {
340 * // `entries` is an array of Cloud Logging entry objects.
341 * // See the `data` property to read the data from the entry.
342 * });
343 *
344 * //-
345 * // To control how many API requests are made and page through the results
346 * // manually, set `autoPaginate` to `false`.
347 * //-
348 * function callback(err, entries, nextQuery, apiResponse) {
349 * if (nextQuery) {
350 * // More results exist.
351 * logging.getEntries(nextQuery, callback);
352 * }
353 * }
354 *
355 * logging.getEntries({
356 * autoPaginate: false
357 * }, callback);
358 *
359 * //-
360 * // If the callback is omitted, we'll return a Promise.
361 * //-
362 * logging.getEntries().then(data => {
363 * const entries = data[0];
364 * });
365 *
366 * ```
367 * @example <caption>include:samples/logs.js</caption>
368 * region_tag:logging_list_log_entries
369 * Another example:
370 *
371 * @example <caption>include:samples/logs.js</caption>
372 * region_tag:logging_list_log_entries_advanced
373 * Another example:
374 */
375 getEntries(options?: GetEntriesRequest): Promise<GetEntriesResponse>;
376 getEntries(callback: GetEntriesCallback): void;
377 getEntries(options: GetEntriesRequest, callback: GetEntriesCallback): void;
378 /**
379 * List the {@link Entry} objects in your logs as a readable object
380 * stream.
381 *
382 * @method Logging#getEntriesStream
383 * @param {GetEntriesRequest} [query] Query object for listing entries.
384 * @returns {ReadableStream} A readable stream that emits {@link Entry}
385 * instances.
386 *
387 * @example
388 * ```
389 * const {Logging} = require('@google-cloud/logging');
390 * const logging = new Logging();
391 *
392 * logging.getEntriesStream()
393 * .on('error', console.error)
394 * .on('data', entry => {
395 * // `entry` is a Cloud Logging entry object.
396 * // See the `data` property to read the data from the entry.
397 * })
398 * .on('end', function() {
399 * // All entries retrieved.
400 * });
401 *
402 * //-
403 * // If you anticipate many results, you can end a stream early to prevent
404 * // unnecessary processing and API requests.
405 * //-
406 * logging.getEntriesStream()
407 * .on('data', function(entry) {
408 * this.end();
409 * });
410 * ```
411 */
412 getEntriesStream(options?: GetEntriesRequest): Duplex;
413 /**
414 * Query object for streaming entries.
415 *
416 * @typedef {object} TailEntriesRequest
417 * @property {Array.<string>|string} [resourceNames] Names of project
418 * resources to stream logs out of.
419 * @property {string} [filter] An
420 * [advanced logs
421 * filter](https://cloud.google.com/logging/docs/view/advanced_filters). An
422 * empty filter matches all log entries.
423 * @property {number} [bufferWindow=2] A setting to balance the tradeoff
424 * between viewing the log entries as they are being written and viewing
425 * them in ascending order.
426 * @property {string} [log] A name of the log specifying to only return
427 * entries from this log.
428 * @property {object} [gaxOptions] Request configuration options, outlined
429 * here: https://googleapis.github.io/gax-nodejs/global.html#CallOptions.
430 */
431 /**
432 * Streaming read of live logs as log entries are ingested. Until the stream
433 * is terminated, it will continue reading logs.
434 *
435 * @method Logging#tailEntries
436 * @param {TailEntriesRequest} [query] Query object for tailing entries.
437 * @returns {DuplexStream} A duplex stream that emits TailEntriesResponses
438 * containing an array of {@link Entry} instances.
439 *
440 * @example
441 * ```
442 * const {Logging} = require('@google-cloud/logging');
443 * const logging = new Logging();
444 *
445 * logging.tailEntries()
446 * .on('error', console.error)
447 * .on('data', resp => {
448 * console.log(resp.entries);
449 * console.log(resp.suppressionInfo);
450 * })
451 * .on('end', function() {
452 * // All entries retrieved.
453 * });
454 *
455 * //-
456 * // If you anticipate many results, you can end a stream early to prevent
457 * // unnecessary processing and API requests.
458 * //-
459 * logging.getEntriesStream()
460 * .on('data', function(entry) {
461 * this.end();
462 * });
463 * ```
464 */
465 tailEntries(options?: TailEntriesRequest): Duplex;
466 /**
467 * Query object for listing entries.
468 *
469 * @typedef {object} GetLogsRequest
470 * @property {boolean} [autoPaginate=true] Have pagination handled
471 * automatically.
472 * @property {object} [gaxOptions] Request configuration options, outlined
473 * here: https://googleapis.github.io/gax-nodejs/global.html#CallOptions.
474 * @property {number} [maxApiCalls] Maximum number of API calls to make.
475 * @property {number} [maxResults] Maximum number of items plus prefixes to
476 * return.
477 * @property {number} [pageSize] Maximum number of logs to return.
478 * @property {string} [pageToken] A previously-returned page token
479 * representing part of the larger set of results to view.
480 */
481 /**
482 * @typedef {array} GetLogsResponse
483 * @property {Log[]} 0 Array of {@link Log} instances.
484 * @property {object} 1 The full API request.
485 * @property {object} 2 The full API response.
486 */
487 /**
488 * @callback GetLogsCallback
489 * @param {?Error} err Request error, if any.
490 * @param {Log[]} logs Array of {@link Log} instances.
491 * @param {object} apiResponse The full API response.
492 */
493 /**
494 * List the entries in your logs.
495 *
496 * See {@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/logs/list|logs.list API Documentation}
497 *
498 * @param {GetLogsRequest} [query] Query object for listing entries.
499 * @param {GetLogsCallback} [callback] Callback function.
500 * @returns {Promise<GetLogsResponse>}
501 *
502 * @example
503 * ```
504 * const {Logging} = require('@google-cloud/logging');
505 * const logging = new Logging();
506 *
507 * logging.getLogs((err, logs) => {
508 * // `logs` is an array of Cloud Logging log objects.
509 * });
510 *
511 * //-
512 * // To control how many API requests are made and page through the results
513 * // manually, set `autoPaginate` to `false`.
514 * //-
515 * function callback(err, entries, nextQuery, apiResponse) {
516 * if (nextQuery) {
517 * // More results exist.
518 * logging.getLogs(nextQuery, callback);
519 * }
520 * }
521 *
522 * logging.getLogs({
523 * autoPaginate: false
524 * }, callback);
525 *
526 * //-
527 * // If the callback is omitted, we'll return a Promise.
528 * //-
529 * logging.getLogs().then(data => {
530 * const entries = data[0];
531 * });
532 *
533 * ```
534 * @example <caption>include:samples/logs.js</caption>
535 * region_tag:logging_list_logs
536 * Another example:
537 */
538 getLogs(options?: GetLogsRequest): Promise<GetLogsResponse>;
539 getLogs(callback: GetLogsCallback): void;
540 getLogs(options: GetLogsRequest, callback: GetLogsCallback): void;
541 /**
542 * List the {@link Log} objects in your project as a readable object stream.
543 *
544 * @method Logging#getLogsStream
545 * @param {GetLogsRequest} [query] Query object for listing entries.
546 * @returns {ReadableStream} A readable stream that emits {@link Log}
547 * instances.
548 *
549 * @example
550 * ```
551 * const {Logging} = require('@google-cloud/logging');
552 * const logging = new Logging();
553 *
554 * logging.getLogsStream()
555 * .on('error', console.error)
556 * .on('data', log => {
557 * // `log` is a Cloud Logging log object.
558 * })
559 * .on('end', function() {
560 * // All logs retrieved.
561 * });
562 *
563 * //-
564 * // If you anticipate many results, you can end a stream early to prevent
565 * // unnecessary processing and API requests.
566 * //-
567 * logging.getLogsStream()
568 * .on('data', log => {
569 * this.end();
570 * });
571 * ```
572 */
573 getLogsStream(options?: GetLogsRequest): Duplex;
574 /**
575 * Query object for listing sinks.
576 *
577 * @typedef {object} GetSinksRequest
578 * @property {boolean} [autoPaginate=true] Have pagination handled
579 * automatically.
580 * @property {object} [gaxOptions] Request configuration options, outlined
581 * here: https://googleapis.github.io/gax-nodejs/global.html#CallOptions.
582 * @property {number} [maxApiCalls] Maximum number of API calls to make.
583 * @property {number} [maxResults] Maximum number of items plus prefixes to
584 * return.
585 * @property {number} [pageSize] Maximum number of logs to return.
586 * @property {string} [pageToken] A previously-returned page token
587 * representing part of the larger set of results to view.
588 */
589 /**
590 * @typedef {array} GetSinksResponse
591 * @property {Sink[]} 0 Array of {@link Sink} instances.
592 * @property {object} 1 The full API response.
593 */
594 /**
595 * @callback GetSinksCallback
596 * @param {?Error} err Request error, if any.
597 * @param {Sink[]} sinks Array of {@link Sink} instances.
598 * @param {object} apiResponse The full API response.
599 */
600 /**
601 * Get the sinks associated with this project.
602 *
603 * See {@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/list|projects.sinks.list API Documentation}
604 *
605 * @param {GetSinksRequest} [query] Query object for listing sinks.
606 * @param {GetSinksCallback} [callback] Callback function.
607 * @returns {Promise<GetSinksResponse>}
608 *
609 * @example
610 * ```
611 * const {Logging} = require('@google-cloud/logging');
612 * const logging = new Logging();
613 *
614 * logging.getSinks((err, sinks) => {
615 * // sinks is an array of Sink objects.
616 * });
617 *
618 * //-
619 * // If the callback is omitted, we'll return a Promise.
620 * //-
621 * logging.getSinks().then(data => {
622 * const sinks = data[0];
623 * });
624 *
625 * ```
626 * @example <caption>include:samples/sinks.js</caption>
627 * region_tag:logging_list_sinks
628 * Another example:
629 */
630 getSinks(options?: GetSinksRequest): Promise<GetSinksResponse>;
631 getSinks(callback: GetSinksCallback): void;
632 getSinks(options: GetSinksRequest, callback: GetSinksCallback): void;
633 /**
634 * Get the {@link Sink} objects associated with this project as a
635 * readable object stream.
636 *
637 * @method Logging#getSinksStream
638 * @param {GetSinksRequest} [query] Query object for listing sinks.
639 * @returns {ReadableStream} A readable stream that emits {@link Sink}
640 * instances.
641 *
642 * @example
643 * ```
644 * const {Logging} = require('@google-cloud/logging');
645 * const logging = new Logging();
646 *
647 * logging.getSinksStream()
648 * .on('error', console.error)
649 * .on('data', sink => {
650 * // `sink` is a Sink object.
651 * })
652 * .on('end', function() {
653 * // All sinks retrieved.
654 * });
655 *
656 * //-
657 * // If you anticipate many results, you can end a stream early to prevent
658 * // unnecessary processing and API requests.
659 * //-
660 * logging.getSinksStream()
661 * .on('data', function(sink) {
662 * this.end();
663 * });
664 * ```
665 */
666 getSinksStream(options: GetSinksRequest): Duplex;
667 /**
668 * Get a reference to a Cloud Logging log.
669 *
670 * See {@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.logs|Log Overview}
671 *
672 * @param {string} name Name of the existing log.
673 * @param {object} [options] Configuration object.
674 * @param {boolean} [options.removeCircular] Replace circular references in
675 * logged objects with a string value, `[Circular]`. (Default: false)
676 * @returns {Log}
677 *
678 * @example
679 * ```
680 * const {Logging} = require('@google-cloud/logging');
681 * const logging = new Logging();
682 * const log = logging.log('my-log');
683 * ```
684 */
685 log(name: string, options?: LogOptions): Log;
686 /**
687 * Get a reference to a Cloud Logging logSync.
688 *
689 * @param {string} name Name of the existing log.
690 * @param {object} transport An optional write stream.
691 * @param {LogSyncOptions} options An optional configuration object.
692 * @returns {LogSync}
693 *
694 * @example
695 * ```
696 * const {Logging} = require('@google-cloud/logging');
697 * const logging = new Logging();
698 *
699 * // Optional: enrich logs with additional context
700 * await logging.setProjectId();
701 * await logging.setDetectedResource();
702 *
703 * // Default transport writes to process.stdout
704 * const log = logging.logSync('my-log');
705 * ```
706 */
707 logSync(name: string, transport?: Writable, options?: LogSyncOptions): LogSync;
708 /**
709 * Get a reference to a Cloud Logging sink.
710 *
711 * See {@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks|Sink Overview}
712 *
713 * @param {string} name Name of the existing sink.
714 * @returns {Sink}
715 *
716 * @example
717 * ```
718 * const {Logging} = require('@google-cloud/logging');
719 * const logging = new Logging();
720 * const sink = logging.sink('my-sink');
721 * ```
722 */
723 sink(name: string): Sink;
724 /**
725 * Funnel all API requests through this method, to be sure we have a project
726 * ID.
727 *
728 * @param {object} config Configuration object.
729 * @param {object} config.gaxOpts GAX options.
730 * @param {function} config.method The gax method to call.
731 * @param {object} config.reqOpts Request options.
732 * @param {function} [callback] Callback function.
733 */
734 request<TResponse = any>(config: RequestConfig, callback?: RequestCallback<TResponse>): Duplex;
735 /**
736 * This method is called when creating a sink with a Bucket destination. The
737 * bucket must first grant proper ACL access to the Cloud Logging
738 * account.
739 *
740 * The parameters are the same as what {@link Logging#createSink} accepts.
741 *
742 * @private
743 */
744 setAclForBucket_(config: CreateSinkRequest): Promise<void>;
745 /**
746 * This method is called when creating a sink with a Dataset destination. The
747 * dataset must first grant proper ACL access to the Cloud Logging
748 * account.
749 *
750 * The parameters are the same as what {@link Logging#createSink} accepts.
751 *
752 * @private
753 */
754 setAclForDataset_(config: CreateSinkRequest): Promise<void>;
755 /**
756 * This method is called when creating a sink with a Topic destination. The
757 * topic must first grant proper ACL access to the Cloud Logging
758 * account.
759 *
760 * The parameters are the same as what {@link Logging#createSink} accepts.
761 *
762 * @private
763 */
764 setAclForTopic_(config: CreateSinkRequest): Promise<void>;
765 /**
766 * setProjectId detects and sets a projectId string on the Logging instance.
767 * It can be invoked once to ensure ensuing LogSync entries have a projectID.
768 * @param reqOpts
769 */
770 setProjectId(reqOpts?: {}): Promise<void>;
771 /**
772 * setResource detects and sets a detectedresource object on the Logging
773 * instance. It can be invoked once to ensure ensuing LogSync entries contain
774 * resource context.
775 */
776 setDetectedResource(): Promise<void>;
777}
778/**
779 * {@link Entry} class.
780 *
781 * @name Logging.Entry
782 * @see Entry
783 * @type {Constructor}
784 */
785export { Entry };
786/**
787 * {@link Log} class.
788 *
789 * @name Logging.Log
790 * @see Log
791 * @type {Constructor}
792 */
793export { Log };
794/**
795 * {@link Severity} enum.
796 */
797export { Severity };
798export { SeverityNames };
799export { assignSeverityToEntries };
800export { formatLogName };
801/**
802 * {@link MonitoredResource} class.
803 *
804 * @name Logging.MonitoredResource
805 * @see MonitoredResource
806 * @type {Interface}
807 */
808export { MonitoredResource };
809/**
810 * {@link LogSync} class.
811 *
812 * @name Logging.LogSync
813 * @see LogSync
814 * @type {Constructor}
815 */
816export { LogSync };
817/**
818 * {@link Sink} class.
819 *
820 * @name Logging.Sink
821 * @see Sink
822 * @type {Constructor}
823 */
824export { Sink };
825/**
826 * The default export of the `@google-cloud/logging` package is the
827 * {@link Logging} class.
828 *
829 * See {@link Logging} and {@link ClientConfig} for client methods and
830 * configuration options.
831 *
832 * @module {Constructor} @google-cloud/logging
833 * @alias nodejs-logging
834 *
835 * @example Install the client library with <a href="https://www.npmjs.com/">npm</a>:
836 * ```
837 * npm install --save @google-cloud/logging
838 *
839 * ```
840 * @example Import the client library
841 * ```
842 * const {Logging} = require('@google-cloud/logging');
843 *
844 * ```
845 * @example Create a client that uses <a href="https://cloud.google.com/docs/authentication/production#providing_credentials_to_your_application">Application Default Credentials (ADC)</a>:
846 * ```
847 * const logging = new Logging();
848 *
849 * ```
850 * @example Create a client with <a href="https://cloud.google.com/docs/authentication/production#obtaining_and_providing_service_account_credentials_manually">explicit credentials</a>:
851 * ```
852 * const logging = new Logging({ projectId: 'your-project-id', keyFilename: '/path/to/keyfile.json'});
853 *
854 * ```
855 * @example <caption>include:samples/quickstart.js</caption>
856 * region_tag:logging_quickstart
857 * Full quickstart example:
858 */
859export { Logging };
860import * as protos from '../protos/protos';
861export { protos };
862export { v2 };
863export * from '@opentelemetry/api';
864
\No newline at end of file