-
Notifications
You must be signed in to change notification settings - Fork 218
Adding logger SDK to reference, with some edits. #714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ import { | |
| } from './logger/common'; | ||
|
|
||
| /** | ||
| * `LogSeverity` indicates the detailed severity of the log entry. See [LogSeverity](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#logseverity) for more. | ||
| * `LogSeverity` indicates the detailed severity of the log entry. See [LogSeverity](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#logseverity). | ||
| */ | ||
| export type LogSeverity = | ||
| | 'DEBUG' | ||
|
|
@@ -20,7 +20,8 @@ export type LogSeverity = | |
| | 'EMERGENCY'; | ||
|
|
||
| /** | ||
| * `LogEntry` represents a structured Cloud Logging entry. All keys aside from `severity` and `message` are | ||
| * `LogEntry` represents a [structured Cloud Logging](https://cloud.google.com/logging/docs/structured-logging) | ||
| * entry. All keys aside from `severity` and `message` are | ||
| * included in the `jsonPayload` of the logged entry. | ||
| */ | ||
| export interface LogEntry { | ||
|
|
@@ -31,7 +32,7 @@ export interface LogEntry { | |
|
|
||
| /** | ||
| * Writes a `LogEntry` to `stdout`/`stderr` (depending on severity). | ||
| * @param entry The LogEntry including severity, message, and any additional structured metadata. | ||
| * @param entry The `LogEntry` including severity, message, and any additional structured metadata. | ||
| */ | ||
| export function write(entry: LogEntry) { | ||
| if (SUPPORTS_STRUCTURED_LOGS) { | ||
|
|
@@ -56,7 +57,7 @@ export function write(entry: LogEntry) { | |
|
|
||
| /** | ||
| * Writes a `DEBUG` severity log. If the last argument provided is a plain object, | ||
| * it will be added to the `jsonPayload` in the Cloud Logging entry. | ||
| * it is added to the `jsonPayload` in the Cloud Logging entry. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's a link to an explanation of jsonPayload: https://cloud.google.com/logging/docs/structured-logging Not sure if that's TMI though If added, this applies to all comments that mention jsonPayload
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, that's a good reference for the guide material, as well as for a top-level comment for |
||
| * @param args Arguments, concatenated into the log message with space separators. | ||
| */ | ||
| export function debug(...args: any[]) { | ||
|
|
@@ -65,7 +66,7 @@ export function debug(...args: any[]) { | |
|
|
||
| /** | ||
| * Writes an `INFO` severity log. If the last argument provided is a plain object, | ||
| * it will be added to the `jsonPayload` in the Cloud Logging entry. | ||
| * it is added to the `jsonPayload` in the Cloud Logging entry. | ||
| * @param args Arguments, concatenated into the log message with space separators. | ||
| */ | ||
| export function log(...args: any[]) { | ||
|
|
@@ -74,7 +75,7 @@ export function log(...args: any[]) { | |
|
|
||
| /** | ||
| * Writes an `INFO` severity log. If the last argument provided is a plain object, | ||
| * it will be added to the `jsonPayload` in the Cloud Logging entry. | ||
| * it is added to the `jsonPayload` in the Cloud Logging entry. | ||
| * @param args Arguments, concatenated into the log message with space separators. | ||
| */ | ||
| export function info(...args: any[]) { | ||
|
|
@@ -83,7 +84,7 @@ export function info(...args: any[]) { | |
|
|
||
| /** | ||
| * Writes a `WARNING` severity log. If the last argument provided is a plain object, | ||
| * it will be added to the `jsonPayload` in the Cloud Logging entry. | ||
| * it is added to the `jsonPayload` in the Cloud Logging entry. | ||
| * @param args Arguments, concatenated into the log message with space separators. | ||
| */ | ||
| export function warn(...args: any[]) { | ||
|
|
@@ -92,13 +93,14 @@ export function warn(...args: any[]) { | |
|
|
||
| /** | ||
| * Writes an `ERROR` severity log. If the last argument provided is a plain object, | ||
| * it will be added to the `jsonPayload` in the Cloud Logging entry. | ||
| * it is added to the `jsonPayload` in the Cloud Logging entry. | ||
| * @param args Arguments, concatenated into the log message with space separators. | ||
| */ | ||
| export function error(...args: any[]) { | ||
| write(entryFromArgs('ERROR', args)); | ||
| } | ||
|
|
||
| /** @hidden */ | ||
| function entryFromArgs(severity: LogSeverity, args: any[]): LogEntry { | ||
| let entry = {}; | ||
| const lastArg = args[args.length - 1]; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will the
LogEntrytype show up in the reference? Can we link to it? Or maybe that happens automatically since it's an argument for the function?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup! TypeDoc creates a link for that.