UNPKG

2.38 kBTypeScriptView Raw
1import { protos, ServiceContext } from '@google-cloud/logging';
2import { LogSeverityFunctions } from '@google-cloud/logging/build/src/utils/log-common';
3import { Options } from '.';
4import { Entry, LogEntry } from '@google-cloud/logging/build/src/entry';
5declare type Callback = (err: Error | null, apiResponse?: {}) => void;
6export declare type MonitoredResource = protos.google.api.MonitoredResource;
7export interface StackdriverData {
8 serviceContext?: ServiceContext;
9 message?: string;
10 metadata?: Metadata | MetadataArg;
11}
12export interface Metadata {
13 stack?: string;
14 httpRequest?: protos.google.logging.type.IHttpRequest;
15 labels?: {};
16 [key: string]: any;
17}
18/*!
19 * Log entry data key to allow users to indicate a trace for the request.
20 */
21export declare const LOGGING_TRACE_KEY = "logging.googleapis.com/trace";
22/*!
23 * Log entry data key to allow users to indicate a spanId for the request.
24 */
25export declare const LOGGING_SPAN_KEY = "logging.googleapis.com/spanId";
26/*!
27 * Log entry data key to allow users to indicate a traceSampled flag for the request.
28 */
29export declare const LOGGING_SAMPLED_KEY = "logging.googleapis.com/trace_sampled";
30/*!
31 * Gets the current fully qualified trace ID when available from the
32 * @google-cloud/trace-agent library in the LogEntry.trace field format of:
33 * "projects/[PROJECT-ID]/traces/[TRACE-ID]".
34 */
35export declare function getCurrentTraceFromAgent(): string | null;
36export declare class LoggingCommon {
37 readonly logName: string;
38 private inspectMetadata;
39 private levels;
40 cloudLog: LogSeverityFunctions;
41 private resource;
42 private serviceContext;
43 private prefix;
44 private labels;
45 private defaultCallback?;
46 redirectToStdout: boolean;
47 static readonly LOGGING_TRACE_KEY = "logging.googleapis.com/trace";
48 static readonly LOGGING_SPAN_KEY = "logging.googleapis.com/spanId";
49 constructor(options?: Options);
50 log(level: string, message: string, metadata: MetadataArg | undefined, callback: Callback): void;
51 entry(metadata?: LogEntry, data?: string | {}): Entry;
52}
53declare type MetadataArg = {
54 stack?: {};
55 /**
56 * set httpRequest to a http.clientRequest object to log it
57 */
58 httpRequest?: protos.google.logging.type.IHttpRequest;
59 labels?: {};
60 timestamp?: {};
61 logName?: string;
62} & {
63 [key: string]: string | {};
64};
65export {};