Skip to content

Commit 3100170

Browse files
introduce Logging support
1 parent 7e75ae1 commit 3100170

19 files changed

Lines changed: 3555 additions & 4 deletions

File tree

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This client supports the following Google Cloud Platform services:
1313
* [Google BigQuery](#google-bigquery)
1414
* [Google Cloud Datastore](#google-cloud-datastore)
1515
* [Google Cloud DNS](#google-cloud-dns)
16+
* [Google Cloud Logging](#google-cloud-logging)
1617
* [Google Cloud Pub/Sub](#google-cloud-pubsub)
1718
* [Google Cloud Storage](#google-cloud-storage)
1819
* [Google Compute Engine](#google-compute-engine)
@@ -209,6 +210,49 @@ zone.export('/zonefile.zone', function(err) {});
209210
```
210211

211212

213+
## Google Cloud Logging
214+
215+
- [API Documentation][gcloud-logging-docs]
216+
- [Official Documentation][cloud-logging-docs]
217+
218+
#### Preview
219+
220+
```js
221+
// Authenticating on a global-basis. You can also authenticate on a per-API-
222+
// basis (see Authentication section above).
223+
var gcloud = require('gcloud')({
224+
projectId: 'my-project',
225+
keyFilename: '/path/to/keyfile.json'
226+
});
227+
228+
var logging = gcloud.logging();
229+
230+
// Create a sink using a Bucket as a destination.
231+
var gcs = gcloud.storage();
232+
233+
dns.createSink('my-new-sink', {
234+
destination: gcs.bucket('my-sink')
235+
}, function(err, sink) {});
236+
237+
// Write a critical entry to a log.
238+
var log = logging.log('compute.googleapis.com');
239+
240+
log.critical({
241+
metadata: {
242+
serviceName: 'compute.googleapis.com'
243+
},
244+
data: {
245+
delegate: process.env.USER
246+
}
247+
}, function(err) {});
248+
249+
// Get indexes from a service like Compute Engine.
250+
var service = logging.service('compute.googleapis.com');
251+
252+
service.getIndexes(function(err, indexes) {});
253+
```
254+
255+
212256
## Google Cloud Pub/Sub
213257

214258
- [API Documentation][gcloud-pubsub-docs]
@@ -433,6 +477,7 @@ Apache 2.0 - See [COPYING](COPYING) for more information.
433477
[gcloud-compute-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs/compute
434478
[gcloud-datastore-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs/datastore
435479
[gcloud-dns-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs/dns
480+
[gcloud-logging-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs/logging
436481
[gcloud-pubsub-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs/pubsub
437482
[gcloud-resource-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs/resource
438483
[gcloud-search-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs/search
@@ -460,6 +505,8 @@ Apache 2.0 - See [COPYING](COPYING) for more information.
460505

461506
[cloud-dns-docs]: https://cloud.google.com/dns/docs
462507

508+
[cloud-logging-docs]: https://cloud.google.com/logging/docs
509+
463510
[cloud-pubsub-docs]: https://cloud.google.com/pubsub/docs
464511

465512
[cloud-resource-docs]: https://cloud.google.com/resource-manager

docs/json/master/logging/.gitkeep

Whitespace-only changes.

docs/site/components/docs/docs-values.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,25 @@ angular.module('gcloud.docs')
135135
]
136136
},
137137

138+
logging: {
139+
title: 'Logging',
140+
_url: '{baseUrl}/logging',
141+
pages: [
142+
{
143+
title: 'Log',
144+
url: '/log'
145+
},
146+
{
147+
title: 'Service',
148+
url: '/service'
149+
},
150+
{
151+
title: 'Sink',
152+
url: '/sink'
153+
}
154+
]
155+
},
156+
138157
pubsub: {
139158
title: 'PubSub',
140159
_url: '{baseUrl}/pubsub',
@@ -240,6 +259,9 @@ angular.module('gcloud.docs')
240259
'>=0.20.0': ['compute'],
241260

242261
// introduce resource api.
243-
'>=0.22.0': ['resource']
262+
'>=0.22.0': ['resource'],
263+
264+
// introduce logging api.
265+
'>=0.25.0': ['logging']
244266
}
245267
});

docs/site/components/docs/docs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ <h3 class="sub-heading">
4444
</article>
4545
<hr>
4646

47-
<article ng-repeat="service in ['bigquery', 'compute', 'datastore', 'dns', 'pubsub', 'resource', 'search', 'storage']"
47+
<article ng-repeat="service in ['bigquery', 'compute', 'datastore', 'dns', 'pubsub', 'logging', 'resource', 'search', 'storage']"
4848
ng-if="isActiveDoc(service)"
4949
ng-include="'site/components/docs/' + service + '-overview.html'">
5050
</article>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<h3>Logging Overview</h3>
2+
<p>
3+
The <code>gcloud.logging</code> method will return a <code>logging</code> object, allowing you to create sinks, write log entries, and more.
4+
</p>
5+
<p>
6+
To learn more about Logging, see the <a href="https://cloud.google.com/logging/docs">What is Google Cloud Logging?</a>
7+
</p>
8+

lib/common/service-object.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ ServiceObject.prototype.request = function(reqOpts, callback) {
312312
})
313313
.join('/');
314314

315-
this.parent.request(reqOpts, callback);
315+
return this.parent.request(reqOpts, callback);
316316
};
317317

318318
module.exports = ServiceObject;

lib/common/service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Service.prototype.request = function(reqOpts, callback) {
8484
// Good: https://.../projects:list
8585
.replace(/\/:/g, ':');
8686

87-
this.makeAuthenticatedRequest(reqOpts, callback);
87+
return this.makeAuthenticatedRequest(reqOpts, callback);
8888
};
8989

9090
module.exports = Service;

lib/index.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,34 @@ var apis = {
108108
*/
109109
dns: require('./dns'),
110110

111+
/**
112+
* <p class="notice">
113+
* **This is a *Beta* release of Google Cloud Logging for Google Compute
114+
* Engine.** This feature is not covered by any SLA or deprecation policy
115+
* and may be subject to backward-incompatible changes.
116+
* </p>
117+
*
118+
* [Google Cloud Logging](https://cloud.google.com/logging/docs) collects and
119+
* stores logs from applications and services on the Google Cloud Platform:
120+
*
121+
* - Export your logs to Google Cloud Storage, Google BigQuery, or Google
122+
* Cloud Pub/Sub.
123+
* - Integrate third-party logs from your virtual machine instances by
124+
* installing the logging agent, `google-fluentd`.
125+
*
126+
* @type {module:logging}
127+
*
128+
* @return {module:logging}
129+
*
130+
* @example
131+
* var gcloud = require('gcloud');
132+
* var logging = gcloud.logging({
133+
* projectId: 'grape-spaceship-123',
134+
* keyFilename: '/path/to/keyfile.json'
135+
* });
136+
*/
137+
logging: require('./logging'),
138+
111139
/**
112140
* [Google Cloud Pub/Sub](https://developers.google.com/pubsub/overview) is a
113141
* reliable, many-to-many, asynchronous messaging service from Google Cloud

0 commit comments

Comments
 (0)