Skip to content
Node.js client for Stackdriver Logging: Store, search, analyze, monitor, and alert on log data and events from Google Cloud Platform and Amazon Web Services (AWS).
Branch: master
Clone or download
yoshi-automation and JustinBeckwith chore: release 5.2.0 (#530)
* updated CHANGELOG.md [ci skip]

* updated package.json [ci skip]

* updated samples/package.json [ci skip]
Latest commit 26bac83 Jul 17, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github chore: move CONTRIBUTING.md to root (#382) Feb 7, 2019
.kokoro build: switch to GitHub magic proxy, for release-please (#519) Jun 19, 2019
proto refactor (typescript): noImplilcitAny (#408) Mar 1, 2019
protos/google/logging chore: update proto docs and code style Feb 26, 2019
samples chore: release 5.2.0 (#530) Jul 17, 2019
smoke-test fix(docs): const logging = require.. contains binary (#338) Dec 5, 2018
src feat: add path template parsing for billing, organizations, and folde… Jul 15, 2019
system-test refactor: log.ts to async-first (#453) May 8, 2019
test refactor: changes formatting of various statements Jun 7, 2019
.eslintignore chore: update nyc and eslint configs (#351) Dec 11, 2018
.eslintrc.yml refactor: go back to prettier, use generated gapic tests (#308) Nov 7, 2018
.gitignore refactor: clean up types and imports (#409) Mar 9, 2019
.jsdoc.js fix(docs): link to reference docs section on googleapis.dev (#521) Jun 25, 2019
.nycrc build: ignore proto files in test coverage (#498) May 28, 2019
.prettierignore refactor: go back to prettier, use generated gapic tests (#308) Nov 7, 2018
.prettierrc refactor: go back to prettier, use generated gapic tests (#308) Nov 7, 2018
.readme-partials.yml feat: add .repo-metadata.json for docs generation (#502) Jun 3, 2019
.repo-metadata.json fix: there is a free tier for logging (#513) Jun 14, 2019
CHANGELOG.md chore: release 5.2.0 (#530) Jul 17, 2019
CODE_OF_CONDUCT.md Repository Migration (#1) Oct 5, 2017
CONTRIBUTING.md docs: update links in contrib guide (#399) Feb 14, 2019
LICENSE chore: update license file (#337) Dec 4, 2018
README.md fix(docs): link to reference docs section on googleapis.dev (#521) Jun 25, 2019
codecov.yaml build: fix codecov uploading on Kokoro (#244) Oct 15, 2018
linkinator.config.json build: use config file for linkinator (#524) Jun 28, 2019
package.json chore: release 5.2.0 (#530) Jul 17, 2019
renovate.json chore: ignore package-lock.json (#186) Aug 7, 2018
synth.metadata feat: add path template parsing for billing, organizations, and folde… Jul 15, 2019
synth.py build: check broken links in generated docs (#358) Jan 15, 2019
tsconfig.json fix: disable skipLibCheck in the tsconfig (#296) Oct 31, 2018
tslint.json refactor: introduce typescript compiler (#246) Oct 20, 2018

README.md

Google Cloud Platform logo

Stackdriver Logging: Node.js Client

release level npm version codecov

Stackdriver Logging allows you to store, search, analyze, monitor, and alert on log data and events from Google Cloud Platform and Amazon Web Services.

Read more about the client libraries for Cloud APIs, including the older Google APIs Client Libraries, in Client Libraries Explained.

Table of contents:

Quickstart

Before you begin

  1. Select or create a Cloud Platform project.
  2. Enable the Stackdriver Logging API.
  3. Set up authentication with a service account so you can access the API from your local workstation.

Installing the client library

npm install @google-cloud/logging

Using the client library

async function quickstart(
  projectId = 'YOUR_PROJECT_ID', // Your Google Cloud Platform project ID
  logName = 'my-log' // The name of the log to write to
) {
  // Imports the Google Cloud client library
  const {Logging} = require('@google-cloud/logging');

  // Creates a client
  const logging = new Logging({projectId});

  // Selects the log to write to
  const log = logging.log(logName);

  // The data to write to the log
  const text = 'Hello, world!';

  // The metadata associated with the entry
  const metadata = {
    resource: {type: 'global'},
  };

  // Prepares a log entry
  const entry = log.entry(metadata, text);

  // Writes the log entry
  await log.write(entry);
  console.log(`Logged: ${text}`);
}

Samples

Samples are in the samples/ directory. The samples' README.md has instructions for running the samples.

Sample Source Code Try it
Fluent source code Open in Cloud Shell
Logs source code Open in Cloud Shell
Quickstart source code Open in Cloud Shell
Sinks source code Open in Cloud Shell

The Stackdriver Logging Node.js Client API Reference documentation also contains samples.

Versioning

This library follows Semantic Versioning.

This library is considered to be General Availability (GA). This means it is stable; the code surface will not change in backwards-incompatible ways unless absolutely necessary (e.g. because of critical security issues) or with an extensive deprecation period. Issues and requests against GA libraries are addressed with the highest priority.

More Information: Google Cloud Platform Launch Stages

Contributing

Contributions welcome! See the Contributing Guide.

License

Apache Version 2.0

See LICENSE

You can’t perform that action at this time.