Skip to content

Commit

Permalink
fix(types): write options dryRun and partialSuccess (#711) (#712)
Browse files Browse the repository at this point in the history
  • Loading branch information
zamnuts committed Feb 19, 2020
1 parent 8ccd960 commit 56a8ed8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ export type DeleteCallback = ApiResponseCallback;

export type MonitoredResource = google.api.IMonitoredResource;
export interface WriteOptions {
dryRun?: boolean;
gaxOptions?: CallOptions;
labels?: {[index: string]: string};
partialSuccess?: boolean;
resource?: MonitoredResource;
}

Expand Down Expand Up @@ -721,9 +723,14 @@ class Log implements LogSeverityFunctions {
* Write options.
*
* @typedef {object} WriteOptions
* @property {boolean} [dryRun] If true, the request should expect normal
* response, but the entries won't be persisted nor exported.
* @property {object} gaxOptions Request configuration options, outlined here:
* https://googleapis.github.io/gax-nodejs/global.html#CallOptions.
* @property {object[]} labels Labels to set on the log.
* @property {boolean} [partialSuccess] Whether valid entries should be
* written even if some other entries fail due to INVALID_ARGUMENT
* or PERMISSION_DENIED errors.
* @property {object} resource A default monitored resource for entries where
* one isn't specified.
*/
Expand Down
12 changes: 12 additions & 0 deletions test/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,18 @@ describe('Log', () => {
await log.write(ENTRY);
});

it('should pass through additional options', async () => {
log.logging.loggingService.writeLogEntries = (
reqOpts: WriteOptions,
gaxOpts: {}
) => {
assert.strictEqual(reqOpts.dryRun, true);
assert.strictEqual(reqOpts.partialSuccess, false);
};

await log.write(ENTRY, {dryRun: true, partialSuccess: false});
});

it('should not truncate entries by default', async () => {
const logger = createLogger();
const entry = new Entry({}, 'hello world'.padEnd(300000, '.'));
Expand Down

0 comments on commit 56a8ed8

Please sign in to comment.