Skip to content

Commit

Permalink
Merge pull request #526 from pact-foundation/fix/FfiLogLevelFilter
Browse files Browse the repository at this point in the history
fix: logFile default to info if undefined, warn if error setting
  • Loading branch information
YOU54F authored Sep 6, 2024
2 parents 9acf43c + a9906c4 commit 4765275
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
11 changes: 7 additions & 4 deletions src/ffi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,14 @@ export const getFfiLib = (
logFile
);
if (logFile) {
logger.debug(
`writing log file at level ${FfiLogLevelFilter[logLevel]} to ${logFile}`
logger.debug(`writing log file at level ${logLevel} to ${logFile}`);
const res = ffiLib.pactffiLogToFile(
logFile,
FfiLogLevelFilter[logLevel] ?? 3
);
const res = ffiLib.pactffiLogToFile(logFile, FfiLogLevelFilter[logLevel]);
logger.debug(`result of writing to file '${res}'`);
if (res !== 0) {
logger.warn(`Failed to write log file to ${logFile}, reason: ${res}`);
}
} else {
ffiLib.pactffiInitWithLogLevel(logLevel);
}
Expand Down
11 changes: 5 additions & 6 deletions src/ffi/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,11 @@ export enum FfiFunctionResult {
}

export enum FfiLogLevelFilter {
LOG_LEVEL_OFF = 0,
LOG_LEVEL_ERROR,
LOG_LEVEL_WARN,
LOG_LEVEL_INFO,
LOG_LEVEL_DEBUG,
LOG_LEVEL_TRACE,
'error' = 1,
'warn' = 2,
'info' = 3,
'debug' = 4,
'trace' = 5,
}

export type Ffi = {
Expand Down

0 comments on commit 4765275

Please sign in to comment.