Stay organized with collections Save and categorize content based on your preferences.
consoleThis class allows the developer to write to the Execution log and to Google Cloud Logging if the script is associated with a standard Cloud Project.
For full support of Cloud Logging and structured logging, use Logger
. The console
methods serialize the objects to strings and do not support jsonPayload
as part of the structured logging LogEntry
.
function measuringExecutionTime() { const label = "myFunction() time"; // Labels the timing log entry. console.time(label); // Starts the timer. try { myFunction(); // Function to time. } catch (e) { // Logs an ERROR message. console.error("myFunction() yielded an error: " + e); } console.timeEnd(label); // Stops the timer, logs execution duration. } function myFunction() { // ... }Methods Method Return type Brief description
error()
void
Outputs a blank ERROR level message to Stackdriver Logging. error(formatOrObject, values)
void
Outputs an ERROR level message to Stackdriver Logging. info()
void
Outputs blank INFO level message to Stackdriver Logging. info(formatOrObject, values)
void
Outputs an INFO level message to Stackdriver Logging. log()
void
Outputs a blank DEBUG level message to Stackdriver Logging. log(formatOrObject, values)
void
Outputs a DEBUG level message to Stackdriver Logging. time(label)
void
Starts a timer you can use to track how long an operation takes. timeEnd(label)
void
Stops a timer that was previously started by calling console.time()
. warn()
void
Outputs a blank WARNING level message to Stackdriver Logging. warn(formatOrObject, values)
void
Outputs a WARNING level message to Stackdriver Logging. Detailed documentation error()
Outputs a blank ERROR level message to Stackdriver Logging.
error(formatOrObject, values)
Outputs an ERROR level message to Stackdriver Logging.
Parameters Name Type DescriptionformatOrObject
Object
a string containing zero or more substitution strings, or a JavaScript object to be logged as a JavaScript object if no other parameters. values
Object...
objects with which to replace substitution strings within the message. This gives you additional control over the format of the output. info()
Outputs blank INFO level message to Stackdriver Logging.
info(formatOrObject, values)
Outputs an INFO level message to Stackdriver Logging.
Parameters Name Type DescriptionformatOrObject
Object
a string containing zero or more substitution strings, or a JavaScript object to be logged as a JavaScript object if no other parameters. values
Object...
objects with which to replace substitution strings within the message. This gives you additional control over the format of the output. log()
Outputs a blank DEBUG level message to Stackdriver Logging.
log(formatOrObject, values)
Outputs a DEBUG level message to Stackdriver Logging.
Parameters Name Type DescriptionformatOrObject
Object
a string containing zero or more substitution strings, or a JavaScript object to be logged as a JavaScript object if no other parameters. values
Object...
objects with which to replace substitution strings within the message. This gives you additional control over the format of the output. time(label)
Starts a timer you can use to track how long an operation takes.
Parameters Name Type Descriptionlabel
String
The name to give the new timer. timeEnd(label)
Stops a timer that was previously started by calling console.time()
. The time duration is logged in Stackdriver.
label
String
the name of the timer to stop. warn()
Outputs a blank WARNING level message to Stackdriver Logging.
warn(formatOrObject, values)
Outputs a WARNING level message to Stackdriver Logging.
Parameters Name Type DescriptionformatOrObject
Object
a string containing zero or more substitution strings, or a JavaScript object to be logged as a JavaScript object if no other parameters. values
Object...
objects with which to replace substitution strings within the message. This gives you additional control over the format of the output.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-02 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-02 UTC."],[[["The `console` class enables developers to write logs to Google Cloud's Stackdriver Logging service with various severity levels (DEBUG, INFO, ERROR, WARNING)."],["It provides methods like `console.log()`, `console.info()`, `console.error()`, and `console.warn()` for logging messages with different severity."],["Developers can use `console.time()` and `console.timeEnd()` to measure the execution time of specific code blocks."],["The `console` methods accept format strings and values for structured logging, allowing objects and other data types to be included in log entries."],["Log entries can be viewed and analyzed in the Stackdriver Logging interface for debugging and monitoring purposes."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4