Skip to content
This repository was archived by the owner on Mar 11, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* limitations under the License.
*/

'use strict';

import {Service} from '@google-cloud/common-grpc';
// tslint:disable-next-line variable-name
const EventId = require('eventid');
Expand Down Expand Up @@ -85,7 +83,7 @@ const eventId = new EventId();
class Entry {
metadata;
data;
constructor(metadata, data) {
constructor(metadata?, data?) {
/**
* @name Entry#metadata
* @type {object}
Expand Down Expand Up @@ -174,4 +172,4 @@ class Entry {
* @name module:@google-cloud/logging.Entry
* @see Entry
*/
module.exports.Entry = Entry;
export {Entry};
19 changes: 9 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@
* limitations under the License.
*/

'use strict';

import * as arrify from 'arrify';
import * as common from '@google-cloud/common-grpc';
import {promisifyAll} from '@google-cloud/promisify';
import {paginator} from '@google-cloud/paginator';
import {replaceProjectIdToken} from '@google-cloud/projectify';
import {promisifyAll} from '@google-cloud/promisify';
import * as arrify from 'arrify';
import * as extend from 'extend';
import {GoogleAuth} from 'google-auth-library';
import * as is from 'is';

const pumpify = require('pumpify');
import * as streamEvents from 'stream-events';
import * as through from 'through2';
Expand All @@ -36,9 +35,9 @@ export {HttpRequest};
const PKG = require('../../package.json');
const v2 = require('./v2');

const {Entry} = require('./entry');
const {Log} = require('./log');
const {Sink} = require('./sink');
import {Entry} from './entry';
import {Log} from './log';
import {Sink} from './sink';

/**
* @namespace google
Expand Down Expand Up @@ -913,7 +912,7 @@ promisifyAll(Logging, {
* @see Entry
* @type {Constructor}
*/
module.exports.Entry = Entry;
export {Entry};

/**
* {@link Log} class.
Expand All @@ -922,7 +921,7 @@ module.exports.Entry = Entry;
* @see Log
* @type {Constructor}
*/
module.exports.Log = Log;
export {Log};

/**
* {@link Sink} class.
Expand All @@ -931,7 +930,7 @@ module.exports.Log = Log;
* @see Sink
* @type {Constructor}
*/
module.exports.Sink = Sink;
export {Sink};

/**
* The default export of the `@google-cloud/logging` package is the
Expand Down
14 changes: 6 additions & 8 deletions src/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@
* limitations under the License.
*/

'use strict';

import * as arrify from 'arrify';
import {promisifyAll} from '@google-cloud/promisify';
import * as arrify from 'arrify';
import * as extend from 'extend';
import * as is from 'is';

import {getDefaultResource} from './metadata';

const snakeCaseKeys = require('snakecase-keys');

const {Entry} = require('./entry');
import {Entry} from './entry';

/**
* A log is a named collection of entries, each entry representing a timestamped
Expand Down Expand Up @@ -204,7 +202,7 @@ class Log {
* region_tag:logging_delete_log
* Another example:
*/
delete(gaxOptions, callback) {
delete(gaxOptions, callback?) {
if (is.fn(gaxOptions)) {
callback = gaxOptions;
gaxOptions = {};
Expand Down Expand Up @@ -387,7 +385,7 @@ class Log {
* const entries = data[0];
* });
*/
getEntries(options, callback) {
getEntries(options, callback?) {
if (is.function(options))
{
callback = options;
Expand Down Expand Up @@ -633,7 +631,7 @@ class Log {
* region_tag:logging_write_log_entry_advanced
* Another example:
*/
write(entry, options, callback) {
write(entry, options?, callback?) {
const self = this;
if (is.fn(options)) {
callback = options;
Expand Down Expand Up @@ -753,4 +751,4 @@ class Log {
* @name module:@google-cloud/logging.Log
* @see Log
*/
module.exports.Log = Log;
export {Log};
2 changes: 0 additions & 2 deletions src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* limitations under the License.
*/

'use strict';

import * as fs from 'fs';
import * as gcpMetadata from 'gcp-metadata';
import {GoogleAuth} from 'google-auth-library';
Expand Down
10 changes: 4 additions & 6 deletions src/sink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* limitations under the License.
*/

'use strict';

import * as common from '@google-cloud/common-grpc';
import {promisifyAll} from '@google-cloud/promisify';
import * as extend from 'extend';
Expand Down Expand Up @@ -93,7 +91,7 @@ class Sink {
* region_tag:logging_create_sink
* Another example:
*/
create(config, callback) {
create(config, callback?) {
this.logging.createSink(this.name, config, callback);
}

Expand Down Expand Up @@ -257,7 +255,7 @@ class Sink {
* const apiResponse = data[0];
* });
*/
setFilter(filter, callback) {
setFilter(filter, callback?) {
this.setMetadata(
{
filter,
Expand Down Expand Up @@ -311,7 +309,7 @@ class Sink {
* region_tag:logging_update_sink
* Another example:
*/
setMetadata(metadata, callback) {
setMetadata(metadata, callback?) {
const self = this;
callback = callback || common.util.noop;
this.getMetadata((err, currentMetadata, apiResponse) => {
Expand Down Expand Up @@ -353,4 +351,4 @@ promisifyAll(Sink);
* @name module:@google-cloud/logging.Sink
* @see Sink
*/
module.exports.Sink = Sink;
export {Sink};
24 changes: 15 additions & 9 deletions system-test/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ describe('Logging', () => {
describe('sinks', () => {
it('should create a sink with a Bucket destination', async () => {
const sink = logging.sink(generateName());
const [_, apiResponse] = await sink.create({
// tslint:disable-next-line no-any
const [_, apiResponse] = await (sink as any).create({
destination: bucket,
});
const destination = 'storage.googleapis.com/' + bucket.name;
Expand All @@ -101,11 +102,13 @@ describe('Logging', () => {

it('should create a sink with a Dataset destination', async () => {
const sink = logging.sink(generateName());
const [_, apiResponse] = await sink.create(
{
destination: dataset,
},
);
// tslint:disable-next-line no-any
const [_, apiResponse] = await (sink as any)
.create(
{
destination: dataset,
},
);

const destination = `bigquery.googleapis.com/datasets/${dataset.id}`;

Expand All @@ -118,7 +121,8 @@ describe('Logging', () => {

it('should create a sink with a Topic destination', async () => {
const sink = logging.sink(generateName());
const [_, apiResponse] = await sink.create({destination: topic});
// tslint:disable-next-line no-any
const [_, apiResponse] = await (sink as any).create({destination: topic});
const destination = 'pubsub.googleapis.com/' + topic.name;

// The projectId may have been replaced depending on how the system
Expand All @@ -138,12 +142,14 @@ describe('Logging', () => {

it('should set metadata', async () => {
const metadata = {filter: FILTER};
const [apiResponse] = await sink.setMetadata(metadata);
// tslint:disable-next-line no-any
const [apiResponse] = await (sink as any).setMetadata(metadata);
assert.strictEqual(apiResponse.filter, FILTER);
});

it('should set a filter', async () => {
const [apiResponse] = await sink.setFilter(FILTER);
// tslint:disable-next-line no-any
const [apiResponse] = await (sink as any).setFilter(FILTER);
assert.strictEqual(apiResponse.filter, FILTER);
});
});
Expand Down
4 changes: 1 addition & 3 deletions test/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
* limitations under the License.
*/

'use strict';

import {Service, util} from '@google-cloud/common-grpc';
import * as assert from 'assert';
import * as extend from 'extend';
import {Service, util} from '@google-cloud/common-grpc';
import * as proxyquire from 'proxyquire';

class FakeGrpcService {
Expand Down
5 changes: 2 additions & 3 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
* limitations under the License.
*/

'use strict';

import {util} from '@google-cloud/common-grpc';
import * as arrify from 'arrify';
import * as assert from 'assert';
import * as extend from 'extend';
import * as proxyquire from 'proxyquire';
import * as through from 'through2';
import {util} from '@google-cloud/common-grpc';

const {v2} = require('../src');
const PKG = require('../../package.json');

Expand Down
8 changes: 3 additions & 5 deletions test/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
* limitations under the License.
*/

'use strict';

import {util} from '@google-cloud/common-grpc';
import * as promisify from '@google-cloud/promisify';
import * as assert from 'assert';
import * as extend from 'extend';
import * as proxyquire from 'proxyquire';
import {util} from '@google-cloud/common-grpc';
import * as promisify from '@google-cloud/promisify';

let promisifed = false;
const fakePromisify = extend({}, promisify, {
Expand All @@ -33,7 +31,7 @@ const fakePromisify = extend({}, promisify, {
},
});

const {Entry} = require('../src');
import {Entry} from '../src';

const originalGetDefaultResource = async () => {
return 'very-fake-resource';
Expand Down
2 changes: 0 additions & 2 deletions test/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* limitations under the License.
*/

'use strict';

import * as assert from 'assert';
import BigNumber from 'bignumber.js';
import * as extend from 'extend';
Expand Down
6 changes: 2 additions & 4 deletions test/sink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
* limitations under the License.
*/

'use strict';

import {util} from '@google-cloud/common-grpc';
import * as promisify from '@google-cloud/promisify';
import * as assert from 'assert';
import * as extend from 'extend';
import * as proxyquire from 'proxyquire';
import * as promisify from '@google-cloud/promisify';
import {util} from '@google-cloud/common-grpc';

let promisifed = false;
const fakePromisify = extend({}, promisify, {
Expand Down