Skip to content

Commit

Permalink
fix: avoid excessive logging, add logLevel config
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenle committed Jul 23, 2024
1 parent d8f39a3 commit 955e35b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/sharp-beans-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@blinkk/root-cms': patch
---

fix: avoid excessive logging, add logLevel config
11 changes: 10 additions & 1 deletion packages/root-cms/core/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ export type CMSPluginOptions = {
experiments?: {
ai?: boolean | CMSAIConfig;
};

/**
* Adjust console output verbosity. Default is `'info'`.
*/
logLevel?: 'info' | 'warn' | 'error' | 'silent' | 'debug';
};

export type CMSPlugin = Plugin & {
Expand Down Expand Up @@ -190,6 +195,8 @@ function getFirebaseApp(gcpProjectId: string): App {
}

export function cmsPlugin(options: CMSPluginOptions): CMSPlugin {
const logLevel = options.logLevel || 'info';

if (!options.firebaseConfig) {
throw new Error(
'missing firebaseConfig. create a new app in the firebase admin console and copy the firebase config object to root.config.ts'
Expand Down Expand Up @@ -298,7 +305,9 @@ export function cmsPlugin(options: CMSPluginOptions): CMSPlugin {
async function getCurrentUser(req: Request): Promise<CMSUser | null> {
const sessionCookie = req.session.getItem(SESSION_COOKIE_AUTH);
if (!sessionCookie) {
console.log('no login session cookie');
if (logLevel === 'debug') {
console.log('no login session cookie');
}
return null;
}

Expand Down

0 comments on commit 955e35b

Please sign in to comment.