UNPKG

27.7 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 { CallOptions } from 'google-gax';
17import { GetEntriesCallback, GetEntriesResponse, Logging } from '.';
18import { Entry, LogEntry } from './entry';
19import { LogSeverityFunctions, WriteOptions as CommonOptions } from './utils/log-common';
20export interface WriteOptions extends CommonOptions {
21 dryRun?: boolean;
22 gaxOptions?: CallOptions;
23 partialSuccess?: boolean;
24}
25export interface GetEntriesRequest {
26 autoPaginate?: boolean;
27 filter?: string;
28 gaxOptions?: CallOptions;
29 log?: string;
30 maxApiCalls?: number;
31 maxResults?: number;
32 orderBy?: string;
33 pageSize?: number;
34 pageToken?: string;
35 resourceNames?: string[] | string;
36}
37export interface TailEntriesRequest {
38 resourceNames?: string[] | string;
39 filter?: string;
40 bufferWindow?: number;
41 log?: string;
42 gaxOptions?: CallOptions;
43}
44export interface LogOptions {
45 removeCircular?: boolean;
46 maxEntrySize?: number;
47 jsonFieldsToTruncate?: string[];
48 defaultWriteDeleteCallback?: ApiResponseCallback;
49 partialSuccess?: boolean;
50}
51export type Metadata = any;
52export type ApiResponse = [Metadata];
53export interface ApiResponseCallback {
54 (err: Error | null, apiResponse?: Metadata): void;
55}
56export type DeleteCallback = ApiResponseCallback;
57/**
58 * A log is a named collection of entries, each entry representing a timestamped
59 * event. Logs can be produced by Google Cloud Platform services, by third-party
60 * services, or by your applications. For example, the log `apache-access` is
61 * produced by the Apache Web Server, but the log
62 * `compute.googleapis.com/activity_log` is produced by Google Compute Engine.
63 *
64 * See {@link https://cloud.google.com/logging/docs/basic-concepts#logs|Introduction to Logs}
65 *
66 * @class
67 *
68 * @param {Logging} logging {@link Logging} instance.
69 * @param {string} name Name of the log.
70 * @param {object} [options] Configuration object.
71 * @param {boolean} [options.removeCircular] Replace circular references in
72 * logged objects with a string value, `[Circular]`. (Default: false)
73 * @param {number} [options.maxEntrySize] A max entry size
74 * @param {string[]} [options.jsonFieldsToTruncate] A list of JSON properties at the given full path to be truncated.
75 * Received values will be prepended to predefined list in the order received and duplicates discarded.
76 * @param {ApiResponseCallback} [options.defaultWriteDeleteCallback] A default global callback to be used for {@link Log#write}
77 * and {@link Log#delete} APIs when {@link ApiResponseCallback} callback was not supplied by caller in function parameters.
78 * Note that {@link LogOptions#defaultWriteDeleteCallback} is useful when {@link Log#write} and {@link Log#delete} APIs are called
79 * without `await` and without callback added explicitly to every call - this way {@link LogOptions#defaultWriteDeleteCallback}
80 * can serve as global callback handler, which for example could be used to catch all errors and eliminate crashes.
81 * @param {boolean} [options.partialSuccess] Global flag indicating Whether a batch's valid entries should be written even if
82 * some other entry failed due to errors. Default is true.
83 * See {@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries/write#body.request_body.FIELDS.partial_success|partialSuccess} for more info.
84 * @example
85 * ```
86 * import {Logging} from '@google-cloud/logging';
87 * import {LogOptions} from '@google-cloud/logging/build/src/log';
88 * const options: LogOptions = {
89 * maxEntrySize: 256,
90 * jsonFieldsToTruncate: [
91 * 'jsonPayload.fields.metadata.structValue.fields.custom.stringValue',
92 * ],
93 * defaultWriteDeleteCallback: (err: any) => {
94 * if (err) {
95 * console.log('Error: ' + err);
96 * }
97 * },
98 * };
99 * const logging = new Logging();
100 * const log = logging.log('syslog', options);
101 * ```
102 */
103declare class Log implements LogSeverityFunctions {
104 formattedName_: string;
105 removeCircular_: boolean;
106 maxEntrySize?: number;
107 logging: Logging;
108 name: string;
109 jsonFieldsToTruncate: string[];
110 defaultWriteDeleteCallback?: ApiResponseCallback;
111 partialSuccess: boolean;
112 constructor(logging: Logging, name: string, options?: LogOptions);
113 /**
114 * Write a log entry with a severity of "ALERT".
115 *
116 * This is a simple wrapper around {@link Log.write|Log.write}. All arguments are
117 * the same as documented there.
118 *
119 * @param {Entry|Entry[]} entry A log entry, or array of entries, to write.
120 * @param {?WriteOptions} [options] Write options
121 * @param {LogWriteCallback} [callback] Callback function.
122 * @returns {Promise<LogWriteResponse>}
123 * @example
124 * ```
125 * const {Logging} = require('@google-cloud/logging');
126 * const logging = new Logging();
127 * const log = logging.log('my-log');
128 *
129 * const entry = log.entry('gce_instance', {
130 * instance: 'my_instance'
131 * });
132 *
133 * log.alert(entry, (err, apiResponse) => {});
134 *
135 * //-
136 * // If the callback is omitted, we'll return a Promise.
137 * //-
138 * log.alert(entry).then(data => {
139 * const apiResponse = data[0];
140 * });
141 * ```
142 */
143 alert(entry: Entry | Entry[], options?: WriteOptions): Promise<ApiResponse>;
144 alert(entry: Entry | Entry[], options: WriteOptions, callback: ApiResponseCallback): void;
145 alert(entry: Entry | Entry[], callback: ApiResponseCallback): void;
146 /**
147 * Write a log entry with a severity of "CRITICAL".
148 *
149 * This is a simple wrapper around {@link Log.write|Log.write}. All arguments are
150 * the same as documented there.
151 *
152 * @param {Entry|Entry[]} entry A log entry, or array of entries, to write.
153 * @param {?WriteOptions} [options] Write options
154 * @param {LogWriteCallback} [callback] Callback function.
155 * @returns {Promise<LogWriteResponse>}
156 * @example
157 * ```
158 * const {Logging} = require('@google-cloud/logging');
159 * const logging = new Logging();
160 * const log = logging.log('my-log');
161 *
162 * const entry = log.entry('gce_instance', {
163 * instance: 'my_instance'
164 * });
165 *
166 * log.critical(entry, (err, apiResponse) => {});
167 *
168 * //-
169 * // If the callback is omitted, we'll return a Promise.
170 * //-
171 * log.critical(entry).then(data => {
172 * const apiResponse = data[0];
173 * });
174 * ```
175 */
176 critical(entry: Entry | Entry[], options?: WriteOptions): Promise<ApiResponse>;
177 critical(entry: Entry | Entry[], options: WriteOptions, callback: ApiResponseCallback): void;
178 critical(entry: Entry | Entry[], callback: ApiResponseCallback): void;
179 /**
180 * Write a log entry with a severity of "DEBUG".
181 *
182 * This is a simple wrapper around {@link Log.write|Log.write}. All arguments are
183 * the same as documented there.
184 *
185 * @param {Entry|Entry[]} entry A log entry, or array of entries, to write.
186 * @param {?WriteOptions} [options] Write options
187 * @param {LogWriteCallback} [callback] Callback function.
188 * @returns {Promise<LogWriteResponse>}
189 * @example
190 * ```
191 * const {Logging} = require('@google-cloud/logging');
192 * const logging = new Logging();
193 * const log = logging.log('my-log');
194 *
195 * const entry = log.entry('gce_instance', {
196 * instance: 'my_instance'
197 * });
198 *
199 * log.debug(entry, (err, apiResponse) => {});
200 *
201 * //-
202 * // If the callback is omitted, we'll return a Promise.
203 * //-
204 * log.debug(entry).then(data => {
205 * const apiResponse = data[0];
206 * });
207 * ```
208 */
209 debug(entry: Entry | Entry[], options?: WriteOptions): Promise<ApiResponse>;
210 debug(entry: Entry | Entry[], options: WriteOptions, callback: ApiResponseCallback): void;
211 debug(entry: Entry | Entry[], callback: ApiResponseCallback): void;
212 /**
213 * @typedef {array} DeleteLogResponse
214 * @property {object} 0 The full API response.
215 */
216 /**
217 * @callback DeleteLogCallback
218 * @param {?Error} err Request error, if any.
219 * @param {object} apiResponse The full API response.
220 */
221 /**
222 * Delete the log.
223 *
224 * See {@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.logs/delete|projects.logs.delete API Documentation}
225 *
226 * @param {object} [gaxOptions] Request configuration options, outlined
227 * here: https://googleapis.github.io/gax-nodejs/global.html#CallOptions.
228 * @param {DeleteLogCallback} [callback] Callback function.
229 * @returns {Promise<DeleteLogResponse>}
230 *
231 * @example
232 * ```
233 * const {Logging} = require('@google-cloud/logging');
234 * const logging = new Logging();
235 * const log = logging.log('my-log');
236 *
237 * log.delete((err, apiResponse) => {
238 * if (!err) {
239 * // The log was deleted.
240 * }
241 * });
242 *
243 * //-
244 * // If the callback is omitted, we'll return a Promise.
245 * //-
246 * log.delete().then(data => {
247 * const apiResponse = data[0];
248 * });
249 *
250 * ```
251 * @example <caption>include:samples/logs.js</caption>
252 * region_tag:logging_delete_log
253 * Another example:
254 */
255 delete(gaxOptions?: CallOptions): Promise<ApiResponse>;
256 delete(gaxOptions: CallOptions, callback: DeleteCallback): void;
257 delete(callback: DeleteCallback): void;
258 /**
259 * Write a log entry with a severity of "EMERGENCY".
260 *
261 * This is a simple wrapper around {@link Log.write|Log.write}. All arguments are
262 * the same as documented there.
263 *
264 * @param {Entry|Entry[]} entry A log entry, or array of entries, to write.
265 * @param {?WriteOptions} [options] Write options
266 * @param {LogWriteCallback} [callback] Callback function.
267 * @returns {Promise<LogWriteResponse>}
268 * @example
269 * ```
270 * const {Logging} = require('@google-cloud/logging');
271 * const logging = new Logging();
272 * const log = logging.log('my-log');
273 *
274 * const entry = log.entry('gce_instance', {
275 * instance: 'my_instance'
276 * });
277 *
278 * log.emergency(entry, (err, apiResponse) => {});
279 *
280 * //-
281 * // If the callback is omitted, we'll return a Promise.
282 * //-
283 * log.emergency(entry).then(data => {
284 * const apiResponse = data[0];
285 * });
286 * ```
287 */
288 emergency(entry: Entry | Entry[], options: WriteOptions, callback: ApiResponseCallback): void;
289 emergency(entry: Entry | Entry[], callback: ApiResponseCallback): void;
290 /**
291 * Create an entry object for this log.
292 *
293 * Using this method will not itself make any API requests. You will use
294 * the object returned in other API calls, such as
295 * {@link Log#write}.
296 *
297 * Note, {@link https://cloud.google.com/logging/quotas|Cloud Logging Quotas and limits}
298 * dictates that the maximum log entry size, including all
299 * [LogEntry Resource properties]{@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry},
300 * cannot exceed _approximately_ 256 KB.
301 *
302 * See {@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry|LogEntry JSON representation}
303 *
304 * @param {?object} metadata See a
305 * [LogEntry
306 * Resource](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry).
307 * @param {object|string} data The data to use as the value for this log
308 * entry.
309 * @returns {Entry}
310 *
311 * @example
312 * ```
313 * const {Logging} = require('@google-cloud/logging');
314 * const logging = new Logging();
315 * const log = logging.log('my-log');
316 *
317 * const metadata = {
318 * resource: {
319 * type: 'gce_instance',
320 * labels: {
321 * zone: 'global',
322 * instance_id: '3'
323 * }
324 * }
325 * };
326 *
327 * const entry = log.entry(metadata, {
328 * delegate: 'my_username'
329 * });
330 *
331 * entry.toJSON();
332 * // {
333 * // logName: 'projects/grape-spaceship-123/logs/syslog',
334 * // resource: {
335 * // type: 'gce_instance',
336 * // labels: {
337 * // zone: 'global',
338 * // instance_id: '3'
339 * // }
340 * // },
341 * // jsonPayload: {
342 * // delegate: 'my_username'
343 * // }
344 * // }
345 * ```
346 */
347 entry(metadata?: LogEntry): Entry;
348 entry(data?: string | {}): Entry;
349 entry(metadata?: LogEntry, data?: string | {}): Entry;
350 /**
351 * Write a log entry with a severity of "ERROR".
352 *
353 * This is a simple wrapper around {@link Log.write|Log.write}. All arguments are
354 * the same as documented there.
355 *
356 * @param {Entry|Entry[]} entry A log entry, or array of entries, to write.
357 * @param {?WriteOptions} [options] Write options
358 * @param {LogWriteCallback} [callback] Callback function.
359 * @returns {Promise<LogWriteResponse>}
360 * @example
361 * ```
362 * const {Logging} = require('@google-cloud/logging');
363 * const logging = new Logging();
364 * const log = logging.log('my-log');
365 *
366 * const entry = log.entry('gce_instance', {
367 * instance: 'my_instance'
368 * });
369 *
370 * log.error(entry, (err, apiResponse) => {});
371 *
372 * //-
373 * // If the callback is omitted, we'll return a Promise.
374 * //-
375 * log.error(entry).then(data => {
376 * const apiResponse = data[0];
377 * });
378 * ```
379 */
380 error(entry: Entry | Entry[], options?: WriteOptions): Promise<ApiResponse>;
381 error(entry: Entry | Entry[], options: WriteOptions, callback: ApiResponseCallback): void;
382 error(entry: Entry | Entry[], callback: ApiResponseCallback): void;
383 /**
384 * This method is a wrapper around {module:logging#getEntries}, but with a
385 * filter specified to only return entries from this log.
386 *
387 * See {@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries/list|entries.list API Documentation}
388 *
389 * @param {GetEntriesRequest} [query] Query object for listing entries.
390 * @param {GetEntriesCallback} [callback] Callback function.
391 * @returns {Promise<GetEntriesResponse>}
392 *
393 * @example
394 * ```
395 * const {Logging} = require('@google-cloud/logging');
396 * const logging = new Logging();
397 * const log = logging.log('my-log');
398 *
399 * log.getEntries((err, entries) => {
400 * // `entries` is an array of Cloud Logging entry objects.
401 * // See the `data` property to read the data from the entry.
402 * });
403 *
404 * //-
405 * // To control how many API requests are made and page through the results
406 * // manually, set `autoPaginate` to `false`.
407 * //-
408 * function callback(err, entries, nextQuery, apiResponse) {
409 * if (nextQuery) {
410 * // More results exist.
411 * log.getEntries(nextQuery, callback);
412 * }
413 * }
414 *
415 * log.getEntries({
416 * autoPaginate: false
417 * }, callback);
418 *
419 * //-
420 * // If the callback is omitted, we'll return a Promise.
421 * //-
422 * log.getEntries().then(data => {
423 * const entries = data[0];
424 * });
425 * ```
426 */
427 getEntries(options?: GetEntriesRequest): Promise<GetEntriesResponse>;
428 getEntries(callback: GetEntriesCallback): void;
429 getEntries(options: GetEntriesRequest, callback: GetEntriesCallback): void;
430 /**
431 * This method is a wrapper around {module:logging#getEntriesStream}, but with
432 * a filter specified to only return {module:logging/entry} objects from this
433 * log.
434 *
435 * @method Log#getEntriesStream
436 * @param {GetEntriesRequest} [query] Query object for listing entries.
437 * @returns {ReadableStream} A readable stream that emits {@link Entry}
438 * instances.
439 *
440 * @example
441 * ```
442 * const {Logging} = require('@google-cloud/logging');
443 * const logging = new Logging();
444 * const log = logging.log('my-log');
445 *
446 * log.getEntriesStream()
447 * .on('error', console.error)
448 * .on('data', entry => {
449 * // `entry` is a Cloud Logging entry object.
450 * // See the `data` property to read the data from the entry.
451 * })
452 * .on('end', function() {
453 * // All entries retrieved.
454 * });
455 *
456 * //-
457 * // If you anticipate many results, you can end a stream early to prevent
458 * // unnecessary processing and API requests.
459 * //-
460 * log.getEntriesStream()
461 * .on('data', function(entry) {
462 * this.end();
463 * });
464 * ```
465 */
466 getEntriesStream(options: GetEntriesRequest): import("stream").Duplex;
467 /**
468 * This method is a wrapper around {module:logging#tailEntries}, but with
469 * a filter specified to only return {module:logging/entry} objects from this
470 * log.
471 *
472 * @method Log#tailEntries
473 * @param {TailEntriesRequest} [query] Query object for tailing entries.
474 * @returns {DuplexStream} A duplex stream that emits TailEntriesResponses
475 * containing an array of {@link Entry} instances.
476 *
477 * @example
478 * ```
479 * const {Logging} = require('@google-cloud/logging');
480 * const logging = new Logging();
481 * const log = logging.log('my-log');
482 *
483 * log.tailEntries()
484 * .on('error', console.error)
485 * .on('data', resp => {
486 * console.log(resp.entries);
487 * console.log(resp.suppressionInfo);
488 * })
489 * .on('end', function() {
490 * // All entries retrieved.
491 * });
492 *
493 * //-
494 * // If you anticipate many results, you can end a stream early to prevent
495 * // unnecessary processing and API requests.
496 * //-
497 * log.tailEntries()
498 * .on('data', function(entry) {
499 * this.end();
500 * });
501 * ```
502 */
503 tailEntries(options?: TailEntriesRequest): import("stream").Duplex;
504 /**
505 * Write a log entry with a severity of "INFO".
506 *
507 * This is a simple wrapper around {@link Log.write|Log.write}. All arguments are
508 * the same as documented there.
509 *
510 * @param {Entry|Entry[]} entry A log entry, or array of entries, to write.
511 * @param {?WriteOptions} [options] Write options
512 * @param {LogWriteCallback} [callback] Callback function.
513 * @returns {Promise<LogWriteResponse>}
514 * @example
515 * ```
516 * const {Logging} = require('@google-cloud/logging');
517 * const logging = new Logging();
518 * const log = logging.log('my-log');
519 *
520 * const entry = log.entry('gce_instance', {
521 * instance: 'my_instance'
522 * });
523 *
524 * log.info(entry, (err, apiResponse) => {});
525 *
526 * //-
527 * // If the callback is omitted, we'll return a Promise.
528 * //-
529 * log.info(entry).then(data => {
530 * const apiResponse = data[0];
531 * });
532 * ```
533 */
534 info(entry: Entry | Entry[], options?: WriteOptions): Promise<ApiResponse>;
535 info(entry: Entry | Entry[], options: WriteOptions, callback: ApiResponseCallback): void;
536 info(entry: Entry | Entry[], callback: ApiResponseCallback): void;
537 /**
538 * Write a log entry with a severity of "NOTICE".
539 *
540 * This is a simple wrapper around {@link Log.write|Log.write}. All arguments are
541 * the same as documented there.
542 *
543 * @param {Entry|Entry[]} entry A log entry, or array of entries, to write.
544 * @param {?WriteOptions} [options] Write options
545 * @param {LogWriteCallback} [callback] Callback function.
546 * @returns {Promise<LogWriteResponse>}
547 * @example
548 * ```
549 * const {Logging} = require('@google-cloud/logging');
550 * const logging = new Logging();
551 * const log = logging.log('my-log');
552 *
553 * const entry = log.entry('gce_instance', {
554 * instance: 'my_instance'
555 * });
556 *
557 * log.notice(entry, (err, apiResponse) => {});
558 *
559 * //-
560 * // If the callback is omitted, we'll return a Promise.
561 * //-
562 * log.notice(entry).then(data => {
563 * const apiResponse = data[0];
564 * });
565 * ```
566 */
567 notice(entry: Entry | Entry[], options?: WriteOptions): Promise<ApiResponse>;
568 notice(entry: Entry | Entry[], options: WriteOptions, callback: ApiResponseCallback): void;
569 notice(entry: Entry | Entry[], callback: ApiResponseCallback): void;
570 /**
571 * Write a log entry with a severity of "WARNING".
572 *
573 * This is a simple wrapper around {@link Log.write|Log.write}. All arguments are
574 * the same as documented there.
575 *
576 * @param {Entry|Entry[]} entry A log entry, or array of entries, to write.
577 * @param {?WriteOptions} [options] Write options
578 * @param {LogWriteCallback} [callback] Callback function.
579 * @returns {Promise<LogWriteResponse>}
580 * @example
581 * ```
582 * const {Logging} = require('@google-cloud/logging');
583 * const logging = new Logging();
584 * const log = logging.log('my-log');
585 *
586 * const entry = log.entry('gce_instance', {
587 * instance: 'my_instance'
588 * });
589 *
590 * log.warning(entry, (err, apiResponse) => {});
591 *
592 * //-
593 * // If the callback is omitted, we'll return a Promise.
594 * //-
595 * log.warning(entry).then(data => {
596 * const apiResponse = data[0];
597 * });
598 * ```
599 */
600 warning(entry: Entry | Entry[], options?: WriteOptions): Promise<ApiResponse>;
601 warning(entry: Entry | Entry[], options: WriteOptions, callback: ApiResponseCallback): void;
602 warning(entry: Entry | Entry[], callback: ApiResponseCallback): void;
603 /**
604 * @typedef {array} LogWriteResponse
605 * @property {object} 0 The full API response.
606 */
607 /**
608 * @callback LogWriteCallback
609 * @param {?Error} err Request error, if any.
610 * @param {object} apiResponse The full API response.
611 */
612 /**
613 * Write options.
614 *
615 * @typedef {object} WriteOptions
616 * @property {boolean} [dryRun] If true, the request should expect normal
617 * response, but the entries won't be persisted nor exported.
618 * @property {object} gaxOptions Request configuration options, outlined here:
619 * https://googleapis.github.io/gax-nodejs/global.html#CallOptions.
620 * @property {object[]} labels Labels to set on the log.
621 * @property {boolean} [partialSuccess] Whether valid entries should be
622 * written even if some other entries fail due to INVALID_ARGUMENT
623 * or PERMISSION_DENIED errors.
624 * @property {object} resource A default monitored resource for entries where
625 * one isn't specified.
626 */
627 /**
628 * Write log entries to Cloud Logging.
629 *
630 * Note, {@link https://cloud.google.com/logging/quotas|Cloud Logging Quotas and limits}
631 * dictates that the maximum cumulative size of all entries per write,
632 * including all [LogEntry Resource properties]{@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry},
633 * cannot exceed _approximately_ 10 MB.
634 *
635 * See {@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries/write|entries.write API Documentation}
636 *
637 * @param {Entry|Entry[]} entry A log entry, or array of entries, to write.
638 * @param {?WriteOptions} [options] Write options
639 * @param {LogWriteCallback} [callback] Callback function.
640 * @returns {Promise<LogWriteResponse>}
641 *
642 * @example
643 * ```
644 * const entry = log.entry('gce_instance', {
645 * instance: 'my_instance'
646 * });
647 *
648 * log.write(entry, (err, apiResponse) => {
649 * if (!err) {
650 * // The log entry was written.
651 * }
652 * });
653 *
654 * //-
655 * // You may also pass multiple log entries to write.
656 * //-
657 * const secondEntry = log.entry('compute.googleapis.com', {
658 * user: 'my_username'
659 * });
660 *
661 * log.write([
662 * entry,
663 * secondEntry
664 * ], (err, apiResponse) => {
665 * if (!err) {
666 * // The log entries were written.
667 * }
668 * });
669 *
670 * //-
671 * // To save some steps, you can also pass in plain values as your entries.
672 * // Note, however, that you must provide a configuration object to specify
673 * // the resource.
674 * //-
675 * const entries = [
676 * {
677 * user: 'my_username'
678 * },
679 * {
680 * home: process.env.HOME
681 * }
682 * ];
683 *
684 * const options = {
685 * resource: 'compute.googleapis.com'
686 * };
687 *
688 * log.write(entries, options, (err, apiResponse) => {});
689 *
690 * //-
691 * // If the callback is omitted, we'll return a Promise.
692 * //-
693 * log.write(entries).then(data => {
694 * const apiResponse = data[0];
695 * });
696 *
697 * ```
698 * @example <caption>include:samples/logs.js</caption>
699 * region_tag:logging_write_log_entry
700 * Another example:
701 *
702 * @example <caption>include:samples/logs.js</caption>
703 * region_tag:logging_write_log_entry_advanced
704 * Another example:
705 */
706 write(entry: Entry | Entry[], options?: WriteOptions): Promise<ApiResponse>;
707 write(entry: Entry | Entry[], options: WriteOptions, callback: ApiResponseCallback): void;
708 write(entry: Entry | Entry[], callback: ApiResponseCallback): void;
709 /**
710 * getOrSetResource looks for GCP service context first at the user
711 * declaration level (snakecasing keys), then in the Logging instance,
712 * before finally detecting a resource from the environment.
713 * The resource is then memoized at the Logging instance level for future use.
714 *
715 * @param options
716 * @private
717 */
718 private getOrSetResource;
719 /**
720 * All entries are passed through here in order be formatted and serialized.
721 * User provided Entry values are formatted per LogEntry specifications.
722 * Read more about the LogEntry format:
723 * https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry
724 *
725 * @private
726 *
727 * @param {object[]} entries - Entry objects.
728 * @returns {object[]} Serialized entries.
729 * @throws if there is an error during serialization.
730 */
731 private decorateEntries;
732 /**
733 * Truncate log entries at maxEntrySize, so that error is not thrown, see:
734 * https://cloud.google.com/logging/quotas
735 *
736 * @private
737 *
738 * @param {object|string} the JSON log entry.
739 * @returns {object|string} truncated JSON log entry.
740 */
741 private truncateEntries;
742 /**
743 * Return an array of log entries with the desired severity assigned.
744 *
745 * @private
746 *
747 * @param {object|object[]} entries - Log entries.
748 * @param {string} severity - The desired severity level.
749 */
750 static assignSeverityToEntries_(entries: Entry | Entry[], severity: string): Entry[];
751 /**
752 * Format the name of a log. A log's full name is in the format of
753 * 'projects/{projectId}/logs/{logName}'.
754 *
755 * @private
756 *
757 * @returns {string}
758 */
759 static formatName_(projectId: string, name: string): string;
760}
761/**
762 * Reference to the {@link Log} class.
763 * @name module:@google-cloud/logging.Log
764 * @see Log
765 */
766export { Log };