Skip to content

Commit

Permalink
Merge pull request #32 from BonnierNews/feature/relax-test-coverage
Browse files Browse the repository at this point in the history
Relax test coverage to 90%
  • Loading branch information
MattiasOlla authored Dec 3, 2024
2 parents a538d0d + 2a2c84f commit 45cc743
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
10 changes: 5 additions & 5 deletions .c8rc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"reporter": ["text", "html"],
"all": true,
"statements": "100",
"branches": "100",
"functions": "100",
"lines": "100",
"exclude": ["coverage", "dist", "test", "index.ts", "eslint.config.js", "tsup.config.ts"]
"statements": "90",
"branches": "90",
"functions": "90",
"lines": "90",
"exclude": ["coverage", "dist", "test", "index.ts", "tsup.config.ts"]
}
10 changes: 3 additions & 7 deletions lib/logging.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pino, {
Level,
DestinationStream as PinoDestinationStream,
Logger as PinoLogger,
LoggerOptions as PinoOptions,
Level,
} from "pino";

import { getStore } from "./middleware";
Expand Down Expand Up @@ -43,7 +43,7 @@ export type DestinationStream = PinoDestinationStream;
* Creates a pino logger that is pre-configured and ready to be used with minimal setup.
*/
export function logger(options: LoggerOptions = {}, stream?: DestinationStream | undefined): Logger {
const env = process.env.NODE_ENV /* c8 ignore next */ || "development";
const env = process.env.NODE_ENV || "development";
const shouldPrettyPrint = [ "development", "test", "dev" ].includes(env) && !stream;

const logLocation = env === "test" && "./logs/test.log";
Expand All @@ -55,7 +55,6 @@ export function logger(options: LoggerOptions = {}, stream?: DestinationStream |
messageKey = "message",
timestamp = () => `,"time": "${new Date().toISOString()}"`,
formatLog,
/* c8 ignore start */
transport = shouldPrettyPrint
? {
target: "pino-pretty",
Expand All @@ -66,7 +65,6 @@ export function logger(options: LoggerOptions = {}, stream?: DestinationStream |
},
}
: undefined,
/* c8 ignore stop */
mixin,
...rest
} = options;
Expand All @@ -78,8 +76,7 @@ export function logger(options: LoggerOptions = {}, stream?: DestinationStream |
messageKey,
timestamp,
formatters: {
level: (label) =>
shouldPrettyPrint ? /* c8 ignore next */ { level: label } : { severity: gcpSeverity(label) },
level: (label) => (shouldPrettyPrint ? { level: label } : { severity: gcpSeverity(label) }),
...(formatLog && { log: formatLog }),
},
transport,
Expand All @@ -104,7 +101,6 @@ function gcpSeverity(label: string) {
return "ERROR";
case "fatal":
return "CRITICAL";
/* c8 ignore next 2 */
default:
return "DEFAULT";
}
Expand Down

0 comments on commit 45cc743

Please sign in to comment.