UNPKG

2.74 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';
5type Callback = (err: Error | null, apiResponse?: {}) => void;
6export 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 * Default library version to be used
32 * Using release-please annotations to update DEFAULT_INSTRUMENTATION_VERSION with latest version.
33 * See https://github.com/googleapis/release-please/blob/main/docs/customizing.md#updating-arbitrary-files
34 */
35export declare const NODEJS_WINSTON_DEFAULT_LIBRARY_VERSION = "5.3.0";
36/*!
37 * Gets the current fully qualified trace ID when available from the
38 * @google-cloud/trace-agent library in the LogEntry.trace field format of:
39 * "projects/[PROJECT-ID]/traces/[TRACE-ID]".
40 */
41export declare function getCurrentTraceFromAgent(): string | null;
42export declare class LoggingCommon {
43 readonly logName: string;
44 private inspectMetadata;
45 private levels;
46 cloudLog: LogSeverityFunctions;
47 private resource;
48 private serviceContext;
49 private prefix;
50 private labels;
51 private defaultCallback?;
52 redirectToStdout: boolean;
53 static readonly LOGGING_TRACE_KEY = "logging.googleapis.com/trace";
54 static readonly LOGGING_SPAN_KEY = "logging.googleapis.com/spanId";
55 constructor(options?: Options);
56 log(level: string, message: string, metadata: MetadataArg | undefined, callback: Callback): void;
57 entry(metadata?: LogEntry, data?: string | {}): Entry;
58}
59export declare function getNodejsLibraryVersion(): string;
60type MetadataArg = {
61 stack?: {};
62 /**
63 * set httpRequest to a http.clientRequest object to log it
64 */
65 httpRequest?: protos.google.logging.type.IHttpRequest;
66 labels?: {};
67 timestamp?: {};
68 logName?: string;
69} & {
70 [key: string]: string | {};
71};
72export {};