How to use the gcloud.logging function in gcloud

To help you get started, we’ve selected a few gcloud examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googleapis / nodejs-logging / samples / export.js View on Github external
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

// [START setup]
// By default, gcloud will authenticate using the service account file specified
// by the GOOGLE_APPLICATION_CREDENTIALS environment variable and use the
// project specified by the GCLOUD_PROJECT environment variable. See
// https://googlecloudplatform.github.io/gcloud-node/#/docs/guides/authentication
var gcloud = require('gcloud');

// Get a reference to the logging component
var logging = gcloud.logging();
// [END setup]

// [START listSinks]
/**
 * @param {Function} callback Callback function.
 */
function listSinksExample (callback) {
  // list all sinks in the authenticated project
  logging.getSinks(function (err, sinks) {
    if (err) {
      return callback(err);
    }

    // Should have received all sinks
    console.log('Found ' + sinks.length + ' sinks');
    callback(null, sinks);
github googleapis / nodejs-logging / samples / write.js View on Github external
/* jshint camelcase:false */
'use strict';

var async = require('async');

// [START write]
// [START setup]
// By default, gcloud will authenticate using the service account file specified
// by the GOOGLE_APPLICATION_CREDENTIALS environment variable and use the
// project specified by the GCLOUD_PROJECT environment variable. See
// https://googlecloudplatform.github.io/gcloud-node/#/docs/guides/authentication
var gcloud = require('gcloud');

// Get a reference to the logging component
var logging = gcloud.logging();
// [END setup]

/**
 * @param {string} logName Name of the log to write to.
 * @param {Function} callback Callback function.
 */
function writeExample (logName, callback) {
  // Get a reference to an existing log
  var log = logging.log(logName);

  // Modify this resource type to match a resource in your project
  // See https://cloud.google.com/logging/docs/api/ref_v2beta1/rest \
  //       /v2beta1/monitoredResourceDescriptors/list
  var resource = {
    type: 'gae_app',
    // This example targets a "App Engine" resource in the default module with
github googleapis / nodejs-logging / samples / list.js View on Github external
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

// [START list]
// [START auth]
// By default, gcloud will authenticate using the service account file specified
// by the GOOGLE_APPLICATION_CREDENTIALS environment variable and use the
// project specified by the GCLOUD_PROJECT environment variable. See
// https://googlecloudplatform.github.io/gcloud-node/#/docs/guides/authentication
var gcloud = require('gcloud');

// Get a reference to the logging component
var logging = gcloud.logging();
// [END auth]

/**
 * @param {Object} [options] Configuration options for the request.
 * @param {Function} callback Callback function.
 */
function listExample (options, callback) {
  if (typeof options === 'function') {
    callback = options;
  }

  // Retrieve the latest some log entries from the authenticated project.
  logging.getEntries(options, function (err, entries, nextQuery, apiResponse) {
    if (err) {
      return callback(err);
    }

gcloud

Google Cloud APIs Client Library for Node.js

Apache-2.0
Latest version published 8 years ago

Package Health Score

69 / 100
Full package analysis