-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: runtime logging activation (#9683)
* feat: runtime logging activation * fix bugs * more fixes * fix lint * fix build * fix more lint * nicer names
- Loading branch information
Showing
9 changed files
with
134 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import * as LOGGING from '../../debugging.ts'; | ||
|
||
type LOG_CONFIG_KEY = keyof typeof LOGGING; | ||
export type LOG_CONFIG = { [key in LOG_CONFIG_KEY]: boolean }; | ||
|
||
export function createLoggingConfig(env: { DEBUG: boolean; TESTING: boolean; PRODUCTION: boolean }, debug: LOG_CONFIG) { | ||
const config = {} as LOG_CONFIG; | ||
const keys = Object.keys(LOGGING) as LOG_CONFIG_KEY[]; | ||
|
||
for (const key of keys) { | ||
if (env.DEBUG || env.TESTING) { | ||
config[key] = true; | ||
} else { | ||
config[key] = debug[key] || false; | ||
} | ||
} | ||
|
||
return config; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { LOG_CONFIG } from './-private/utils/logging'; | ||
|
||
const RuntimeConfig = { | ||
debug: {}, | ||
}; | ||
|
||
export function getRuntimeConfig() { | ||
return RuntimeConfig; | ||
} | ||
|
||
/** | ||
* Upserts the specified logging configuration into the runtime | ||
* config. | ||
* | ||
* globalThis.setWarpDriveLogging({ LOG_PAYLOADS: true } }); | ||
* | ||
* @typedoc | ||
*/ | ||
export function setLogging(config: Partial<LOG_CONFIG>) { | ||
Object.assign(RuntimeConfig.debug, config); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters