Skip to content

Commit 7484f94

Browse files
jmdobryAce Nassri
authored andcommitted
Change quickstart style. (#221)
* Change quickstart style. * Fix test.
1 parent a379704 commit 7484f94

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

handwritten/nodejs-logging-winston/samples/quickstart.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,28 @@
1414
'use strict';
1515

1616
// [START logging_quickstart]
17-
// Imports and instantiates the Google Cloud client library
18-
const logging = require('@google-cloud/logging')({
19-
projectId: 'YOUR_PROJECT_ID'
17+
// Imports the Google Cloud client library
18+
const Logging = require('@google-cloud/logging');
19+
20+
// Your Google Cloud Platform project ID
21+
const projectId = 'YOUR_PROJECT_ID';
22+
23+
// Instantiates a client
24+
const loggingClient = Logging({
25+
projectId: projectId
2026
});
2127

28+
// The name of the log to write to
29+
const logName = 'my-log';
2230
// Selects the log to write to
23-
const log = logging.log('my-log');
31+
const log = loggingClient.log(logName);
32+
33+
// The data to write to the log
34+
const text = 'Hello, world!';
35+
// The resource associated with the data
36+
const resource = { type: 'global' };
2437
// Prepares a log entry
25-
const entry = log.entry({ type: 'global' }, 'Hello, world!');
38+
const entry = log.entry(resource, text);
2639

2740
// Writes the log entry
2841
log.write(entry, (err) => {

0 commit comments

Comments
 (0)