Class console
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
কনসোল এই শ্রেণীটি বিকাশকারীকে এক্সিকিউশন লগ এবং Google ক্লাউড লগিং- এ লিখতে অনুমতি দেয় যদি স্ক্রিপ্টটি একটি আদর্শ ক্লাউড প্রকল্পের সাথে যুক্ত থাকে।
ক্লাউড লগিং এবং কাঠামোগত লগিংয়ের সম্পূর্ণ সমর্থনের জন্য, Logger
ব্যবহার করুন। console
পদ্ধতি অবজেক্টকে স্ট্রিং-এ সিরিয়ালাইজ করে এবং স্ট্রাকচার্ড লগিং Log Entry
অংশ হিসেবে json Payload
সমর্থন করে না।
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() {
// ...
}
পদ্ধতি
পদ্ধতি | রিটার্ন টাইপ | সংক্ষিপ্ত বিবরণ |
---|
error() | void | স্ট্যাকড্রাইভার লগিং-এ একটি ফাঁকা ERROR স্তরের বার্তা আউটপুট করে। |
error(formatOrObject, values) | void | স্ট্যাকড্রাইভার লগিং-এ একটি ERROR স্তরের বার্তা আউটপুট করে। |
info() | void | স্ট্যাকড্রাইভার লগিং-এ ফাঁকা INFO স্তরের বার্তা আউটপুট করে। |
info(formatOrObject, values) | void | স্ট্যাকড্রাইভার লগিং-এ একটি INFO স্তরের বার্তা আউটপুট করে। |
log() | void | স্ট্যাকড্রাইভার লগিং-এ একটি ফাঁকা DEBUG স্তরের বার্তা আউটপুট করে। |
log(formatOrObject, values) | void | স্ট্যাকড্রাইভার লগিং-এ একটি DEBUG স্তরের বার্তা আউটপুট করে। |
time(label) | void | একটি টাইমার শুরু করে যা আপনি একটি অপারেশন কতক্ষণ সময় নেয় তা ট্র্যাক করতে ব্যবহার করতে পারেন। |
time End(label) | void | একটি টাইমার বন্ধ করে যা পূর্বে console.time() কল করে শুরু হয়েছিল। |
warn() | void | স্ট্যাকড্রাইভার লগিং-এ একটি ফাঁকা সতর্কতা স্তরের বার্তা আউটপুট করে। |
warn(formatOrObject, values) | void | স্ট্যাকড্রাইভার লগিং-এ একটি সতর্কতা স্তরের বার্তা আউটপুট করে। |
বিস্তারিত ডকুমেন্টেশন
error()
স্ট্যাকড্রাইভার লগিং-এ একটি ফাঁকা ERROR স্তরের বার্তা আউটপুট করে।
স্ট্যাকড্রাইভার লগিং-এ একটি ERROR স্তরের বার্তা আউটপুট করে।
পরামিতি
নাম | টাইপ | বর্ণনা |
---|
format Or Object | Object | শূন্য বা তার বেশি প্রতিস্থাপন স্ট্রিং সম্বলিত একটি স্ট্রিং, অথবা অন্য কোনো পরামিতি না থাকলে একটি জাভাস্ক্রিপ্ট অবজেক্ট হিসেবে লগ ইন করার জন্য একটি জাভাস্ক্রিপ্ট অবজেক্ট। |
values | Object... | বার্তার মধ্যে প্রতিস্থাপন স্ট্রিং প্রতিস্থাপন করার জন্য বস্তু। এটি আপনাকে আউটপুটের বিন্যাসের উপর অতিরিক্ত নিয়ন্ত্রণ দেয়। |
info()
স্ট্যাকড্রাইভার লগিং-এ ফাঁকা INFO স্তরের বার্তা আউটপুট করে।
স্ট্যাকড্রাইভার লগিং-এ একটি INFO স্তরের বার্তা আউটপুট করে।
পরামিতি
নাম | টাইপ | বর্ণনা |
---|
format Or Object | Object | শূন্য বা তার বেশি প্রতিস্থাপন স্ট্রিং সম্বলিত একটি স্ট্রিং, অথবা অন্য কোনো পরামিতি না থাকলে একটি জাভাস্ক্রিপ্ট অবজেক্ট হিসেবে লগ ইন করার জন্য একটি জাভাস্ক্রিপ্ট অবজেক্ট। |
values | Object... | বার্তার মধ্যে প্রতিস্থাপন স্ট্রিং প্রতিস্থাপন করার জন্য বস্তু। এটি আপনাকে আউটপুটের বিন্যাসের উপর অতিরিক্ত নিয়ন্ত্রণ দেয়। |
log()
স্ট্যাকড্রাইভার লগিং-এ একটি ফাঁকা DEBUG স্তরের বার্তা আউটপুট করে।
স্ট্যাকড্রাইভার লগিং-এ একটি DEBUG স্তরের বার্তা আউটপুট করে।
পরামিতি
নাম | টাইপ | বর্ণনা |
---|
format Or Object | Object | শূন্য বা তার বেশি প্রতিস্থাপন স্ট্রিং সম্বলিত একটি স্ট্রিং, অথবা অন্য কোনো পরামিতি না থাকলে একটি জাভাস্ক্রিপ্ট অবজেক্ট হিসেবে লগ ইন করার জন্য একটি জাভাস্ক্রিপ্ট অবজেক্ট। |
values | Object... | বার্তার মধ্যে প্রতিস্থাপন স্ট্রিং প্রতিস্থাপন করার জন্য বস্তু। এটি আপনাকে আউটপুটের বিন্যাসের উপর অতিরিক্ত নিয়ন্ত্রণ দেয়। |
time(label)
একটি টাইমার শুরু করে যা আপনি একটি অপারেশন কতক্ষণ সময় নেয় তা ট্র্যাক করতে ব্যবহার করতে পারেন।
পরামিতি
নাম | টাইপ | বর্ণনা |
---|
label | String | নতুন টাইমার দেওয়ার নাম। |
time End(label)
একটি টাইমার বন্ধ করে যা পূর্বে console.time()
কল করে শুরু হয়েছিল। স্ট্যাকড্রাইভারে লগ ইন করার সময়কাল।
পরামিতি
নাম | টাইপ | বর্ণনা |
---|
label | String | থামার টাইমারের নাম। |
warn()
স্ট্যাকড্রাইভার লগিং-এ একটি ফাঁকা সতর্কতা স্তরের বার্তা আউটপুট করে।
স্ট্যাকড্রাইভার লগিং-এ একটি সতর্কতা স্তরের বার্তা আউটপুট করে।
পরামিতি
নাম | টাইপ | বর্ণনা |
---|
format Or Object | Object | শূন্য বা তার বেশি প্রতিস্থাপন স্ট্রিং সম্বলিত একটি স্ট্রিং, অথবা অন্য কোনো পরামিতি না থাকলে একটি জাভাস্ক্রিপ্ট অবজেক্ট হিসেবে লগ ইন করার জন্য একটি জাভাস্ক্রিপ্ট অবজেক্ট। |
values | Object... | বার্তার মধ্যে প্রতিস্থাপন স্ট্রিং প্রতিস্থাপন করার জন্য বস্তু। এটি আপনাকে আউটপুটের বিন্যাসের উপর অতিরিক্ত নিয়ন্ত্রণ দেয়। |
অন্য কিছু উল্লেখ না করা থাকলে, এই পৃষ্ঠার কন্টেন্ট Creative Commons Attribution 4.0 License-এর অধীনে এবং কোডের নমুনাগুলি Apache 2.0 License-এর অধীনে লাইসেন্স প্রাপ্ত। আরও জানতে, Google Developers সাইট নীতি দেখুন। Java হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-07-24 UTC-তে শেষবার আপডেট করা হয়েছে।
[null,null,["2025-07-24 UTC-তে শেষবার আপডেট করা হয়েছে।"],[[["\u003cp\u003eThe \u003ccode\u003econsole\u003c/code\u003e class enables developers to write logs to Google Cloud's Stackdriver Logging service with various severity levels (DEBUG, INFO, ERROR, WARNING).\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods like \u003ccode\u003econsole.log()\u003c/code\u003e, \u003ccode\u003econsole.info()\u003c/code\u003e, \u003ccode\u003econsole.error()\u003c/code\u003e, and \u003ccode\u003econsole.warn()\u003c/code\u003e for logging messages with different severity.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can use \u003ccode\u003econsole.time()\u003c/code\u003e and \u003ccode\u003econsole.timeEnd()\u003c/code\u003e to measure the execution time of specific code blocks.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003econsole\u003c/code\u003e methods accept format strings and values for structured logging, allowing objects and other data types to be included in log entries.\u003c/p\u003e\n"],["\u003cp\u003eLog entries can be viewed and analyzed in the Stackdriver Logging interface for debugging and monitoring purposes.\u003c/p\u003e\n"]]],[],null,["# Class console\n\nconsole\n\nThis class allows the developer to write to the Execution log and to [Google Cloud Logging](https://cloud.google.com/logging) if the script is associated with\na [standard\nCloud Project](https://developers.google.com/apps-script/guides/cloud-platform-projects#standard).\n\nFor full support of Cloud Logging and structured logging, use [Logger](/apps-script/reference/base/logger). The `console` methods\nserialize the objects to strings and do not support `json``Payload` as part of the structured\nlogging [`Log``Entry`](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry).\n\n```javascript\nfunction measuringExecutionTime() {\n const label = \"myFunction() time\"; // Labels the timing log entry.\n console.time(label); // Starts the timer.\n try {\n myFunction(); // Function to time.\n } catch (e) {\n // Logs an ERROR message.\n console.error(\"myFunction() yielded an error: \" + e);\n }\n console.timeEnd(label); // Stops the timer, logs execution duration.\n}\n\nfunction myFunction() {\n // ...\n}\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|-----------------------------------------------------------|-------------|------------------------------------------------------------------------|\n| [error()](#error()) | `void` | Outputs a blank ERROR level message to Stackdriver Logging. |\n| [error(formatOrObject, values)](#error(Object,Object...)) | `void` | Outputs an ERROR level message to Stackdriver Logging. |\n| [info()](#info()) | `void` | Outputs blank INFO level message to Stackdriver Logging. |\n| [info(formatOrObject, values)](#info(Object,Object...)) | `void` | Outputs an INFO level message to Stackdriver Logging. |\n| [log()](#log()) | `void` | Outputs a blank DEBUG level message to Stackdriver Logging. |\n| [log(formatOrObject, values)](#log(Object,Object...)) | `void` | Outputs a DEBUG level message to Stackdriver Logging. |\n| [time(label)](#time(String)) | `void` | Starts a timer you can use to track how long an operation takes. |\n| [timeEnd(label)](#timeEnd(String)) | `void` | Stops a timer that was previously started by calling `console.time()`. |\n| [warn()](#warn()) | `void` | Outputs a blank WARNING level message to Stackdriver Logging. |\n| [warn(formatOrObject, values)](#warn(Object,Object...)) | `void` | Outputs a WARNING level message to Stackdriver Logging. |\n\nDetailed documentation\n----------------------\n\n### `error()`\n\nOutputs a blank ERROR level message to Stackdriver Logging.\n\n*** ** * ** ***\n\n### `error(formatOrObject, values)`\n\nOutputs an ERROR level message to Stackdriver Logging.\n\n#### Parameters\n\n| Name | Type | Description |\n|----------------------|-------------|-------------------------------------------------------------------------------------------------------------------------------------------|\n| `format``Or``Object` | `Object` | a string containing zero or more substitution strings, or a JavaScript object to be logged as a JavaScript object if no other parameters. |\n| `values` | `Object...` | objects with which to replace substitution strings within the message. This gives you additional control over the format of the output. |\n\n*** ** * ** ***\n\n### `info()`\n\nOutputs blank INFO level message to Stackdriver Logging.\n\n*** ** * ** ***\n\n### `info(formatOrObject, values)`\n\nOutputs an INFO level message to Stackdriver Logging.\n\n#### Parameters\n\n| Name | Type | Description |\n|----------------------|-------------|-------------------------------------------------------------------------------------------------------------------------------------------|\n| `format``Or``Object` | `Object` | a string containing zero or more substitution strings, or a JavaScript object to be logged as a JavaScript object if no other parameters. |\n| `values` | `Object...` | objects with which to replace substitution strings within the message. This gives you additional control over the format of the output. |\n\n*** ** * ** ***\n\n### `log()`\n\nOutputs a blank DEBUG level message to Stackdriver Logging.\n\n*** ** * ** ***\n\n### `log(formatOrObject, values)`\n\nOutputs a DEBUG level message to Stackdriver Logging.\n\n#### Parameters\n\n| Name | Type | Description |\n|----------------------|-------------|-------------------------------------------------------------------------------------------------------------------------------------------|\n| `format``Or``Object` | `Object` | a string containing zero or more substitution strings, or a JavaScript object to be logged as a JavaScript object if no other parameters. |\n| `values` | `Object...` | objects with which to replace substitution strings within the message. This gives you additional control over the format of the output. |\n\n*** ** * ** ***\n\n### `time(label)`\n\nStarts a timer you can use to track how long an operation takes.\n\n#### Parameters\n\n| Name | Type | Description |\n|---------|----------|---------------------------------|\n| `label` | `String` | The name to give the new timer. |\n\n*** ** * ** ***\n\n### `time``End(label)`\n\nStops a timer that was previously started by calling `console.time()`. The time duration\nis logged in Stackdriver.\n\n#### Parameters\n\n| Name | Type | Description |\n|---------|----------|--------------------------------|\n| `label` | `String` | the name of the timer to stop. |\n\n*** ** * ** ***\n\n### `warn()`\n\nOutputs a blank WARNING level message to Stackdriver Logging.\n\n*** ** * ** ***\n\n### `warn(formatOrObject, values)`\n\nOutputs a WARNING level message to Stackdriver Logging.\n\n#### Parameters\n\n| Name | Type | Description |\n|----------------------|-------------|-------------------------------------------------------------------------------------------------------------------------------------------|\n| `format``Or``Object` | `Object` | a string containing zero or more substitution strings, or a JavaScript object to be logged as a JavaScript object if no other parameters. |\n| `values` | `Object...` | objects with which to replace substitution strings within the message. This gives you additional control over the format of the output. |"]]