File tree Expand file tree Collapse file tree
handwritten/nodejs-logging-winston/samples Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
2841log . write ( entry , ( err ) => {
You can’t perform that action at this time.
0 commit comments