Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax test coverage to 90% #32

Merged
merged 2 commits into from
Dec 3, 2024
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
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
Loading