-
Notifications
You must be signed in to change notification settings - Fork 62
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
feat: add getLogs() and getLogsStream() #692
feat: add getLogs() and getLogsStream() #692
Conversation
@@ -97,6 +98,20 @@ describe('Logging', () => { | |||
await getAndDelete(logging.getSinks.bind(logging)); | |||
} | |||
|
|||
async function deleteLogs() { | |||
const [logs] = await logging.getLogs(); |
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.
Using getLogs()
and a naming convention consistent with the other test resources, we can clean up all test logs that are matched after each test run.
Codecov Report
@@ Coverage Diff @@
## master #692 +/- ##
==========================================
+ Coverage 68.24% 68.81% +0.56%
==========================================
Files 36 36
Lines 10604 10828 +224
Branches 174 189 +15
==========================================
+ Hits 7237 7451 +214
- Misses 3366 3376 +10
Partials 1 1
Continue to review full report at Codecov.
|
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.
LGTM, but please let @bcoe have a look too.
async function listLogs() { | ||
// [START logging_list_logs] | ||
// Imports the Google Cloud client library | ||
const {Logging} = require('@google-cloud/logging'); |
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.
If this got embedded in cloud.google.com, the code inside of the region tag would have a top level await. That means folks couldn't reasonably copy and paste the sample without making changes. Instead, can we follow a model that introduces an async wrapper method? For Example:
async function listLogsMain() {
// [START logging_list_logs]
// Imports the Google Cloud client library
const {Logging} = require('@google-cloud/logging');
// Creates a client
const logging = new Logging();
async function listLogs() {
const [logs] = await logging.getLogs();
console.log('Logs:');
logs.forEach(log => {
console.log(log.name);
});
}
listLogs();
// [END logging_list_logs]
}
It does leave a hanging promise, but at least this way the sample is copy/pastable.
RE: #550
This adds a new method,
logging.getLogs()
andlogging.getLogsStream()
using the logs.list API: https://cloud.google.com/logging/docs/reference/v2/rest/v2/logs/list