Skip to content

Commit

Permalink
feat(logging): Add logLevel to Stub options, and add logDir and logLe…
Browse files Browse the repository at this point in the history
…vel to Verifier options
  • Loading branch information
TimothyJones committed Aug 10, 2020
1 parent 239c7a7 commit acc0579
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ var server = pact.createServer({
| `port` | false | number | Port number that the server runs on, defaults to random available port |
| `host` | false | string | Host on which to bind the server on, defaults to 'localhost'. Supports '0.0.0.0' to bind on all IPv4 addresses on the local machine. |
| `log` | false | string | File to log output on relative to current working directory, defaults to none |
| `logLevel` | false | LogLevel (string) | Log level to pass to the pact core. One of "DEBUG", "ERROR", "WARN", "INFO" |
| `ssl` | false | boolean | Create a self-signed SSL cert to run the server over HTTPS , defaults to `false` |
| `sslcert` | false | string | Path to a custom self-signed SSL cert file, 'ssl' option must be set to true to use this option, defaults to none |
| `sslkey` | false | string | Path a custom key and self-signed SSL cert key file, 'ssl' option must be set to true to use this, defaults to none |
Expand Down Expand Up @@ -292,6 +293,9 @@ pact.verifyPacts({
| `timeout` | false | number | The duration in ms we should wait to confirm verification process was successful. Defaults to 30000. |
| `format` | false | string | What format the verification results are printed in. Options are `json`, `xml`, `progress` and `RspecJunitFormatter` (which is a synonym for `xml`) |
| `verbose` | false | boolean | Enables verbose output for underlying pact binary. |
| `logDir` | false | string | Directory to output the pact.log file to
| `logLevel` | false | LogLevel (string) | Log level. One of "DEBUG", "ERROR", "WARN", "INFO" |


### Pact Broker Publishing

Expand Down Expand Up @@ -383,6 +387,7 @@ var server = pact.createStub({
| port | false | number | Port number that the server runs on, defaults to random available port |
| host | false | string | Host on which to bind the server on, defaults to 'localhost'. Supports '0.0.0.0' to bind on all IPv4 addresses on the local machine. |
| log | false | string | File to log output on relative to current working directory, defaults to none |
| logLevel | false | LogLevel (string) | Log level to pass to the pact core. One of "DEBUG", "ERROR", "WARN", "INFO" |
| ssl | false | boolean | Create a self-signed SSL cert to run the server over HTTPS , defaults to 'false' |
| sslcert | false | string | Path to a custom self-signed SSL cert file, 'ssl' option must be set to true to use this option. Defaults false | to none |
| sslkey | false | string | Path a custom key and self-signed SSL cert key file, 'ssl' option must be set to true to use this option false. Defaults to none |
Expand Down
4 changes: 1 addition & 3 deletions src/server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AbstractService } from './service';
import { AbstractService, LogLevel } from './service';
import { deprecate } from 'util';
import pact from './pact-standalone';
import path = require('path');
Expand Down Expand Up @@ -122,5 +122,3 @@ export interface ServerOptions {
logLevel?: LogLevel;
pactFileWriteMode?: 'overwrite' | 'update' | 'merge';
}

export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
3 changes: 3 additions & 0 deletions src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,11 @@ export interface ServiceOptions {
sslcert?: string;
sslkey?: string;
log?: string;
logLevel?: LogLevel;
}

export type LogLevel = 'debug' | 'info' | 'warn' | 'error';

export interface HTTPConfig {
uri: string;
method: string;
Expand Down
4 changes: 3 additions & 1 deletion src/stub.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DEFAULT_ARG } from './spawn';
import { AbstractService } from './service';
import { AbstractService, LogLevel } from './service';
import { deprecate } from 'util';

import pact from './pact-standalone';
Expand Down Expand Up @@ -29,6 +29,7 @@ export class Stub extends AbstractService {
port: '--port',
host: '--host',
log: '--log',
logLevel: '--log-level',
ssl: '--ssl',
sslcert: '--sslcert',
sslkey: '--sslkey',
Expand All @@ -49,4 +50,5 @@ export interface StubOptions {
sslcert?: string;
sslkey?: string;
log?: string;
logLevel?: LogLevel;
}
5 changes: 5 additions & 0 deletions src/verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const unixify = require('unixify');

import fs = require('fs');
import { deprecate } from 'util';
import { LogLevel } from './service';

export class Verifier {
public static create = deprecate(
Expand Down Expand Up @@ -44,6 +45,8 @@ export class Verifier {
monkeypatch: '--monkeypatch',
format: '--format',
out: '--out',
logDir: '--log-dir',
logLevel: '--log-level',
};

constructor(options: VerifierOptions) {
Expand Down Expand Up @@ -310,6 +313,8 @@ interface CurrentVerifierOptions {
monkeypatch?: string;
format?: 'json' | 'xml' | 'progress' | 'RspecJunitFormatter';
out?: string;
logDir?: string;
logLevel?: LogLevel;
}

interface DeprecatedVerifierOptions {
Expand Down

0 comments on commit acc0579

Please sign in to comment.