@prairielearn/logger 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +16 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @prairielearn/logger
|
|
2
2
|
|
|
3
|
+
## 3.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 35ca957: Add `withoutLogging` utility to `@prairielearn/logger` for temporarily silencing logger output during test execution.
|
|
8
|
+
|
|
9
|
+
## 3.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 8bdf6ea: Upgrade all JavaScript dependencies
|
|
14
|
+
|
|
3
15
|
## 3.0.0
|
|
4
16
|
|
|
5
17
|
### Major Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Temporarily silence all logger output while executing the provided function.
|
|
3
|
+
*
|
|
4
|
+
* @param fn - The function to run with the logger silenced.
|
|
5
|
+
* @returns The result of the function.
|
|
6
|
+
*/
|
|
7
|
+
export declare function withoutLogging<T>(fn: () => T | Promise<T>): Promise<T>;
|
|
1
8
|
export declare const logger: import("winston").Logger;
|
|
2
9
|
interface AddFileLoggingOptions {
|
|
3
10
|
filename: string;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM,0BAOjB,CAAC;AAEH,UAAU,qBAAqB;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,qBAAqB,QAQ5D","sourcesContent":["import { format } from 'logform';\nimport { createLogger, transports } from 'winston';\n\nexport const logger = createLogger({\n transports: [\n new transports.Console({\n level: 'info',\n format: format.combine(format.colorize(), format.simple()),\n }),\n ],\n});\n\ninterface AddFileLoggingOptions {\n filename: string;\n level?: string;\n}\n\nexport function addFileLogging(options: AddFileLoggingOptions) {\n logger.add(\n new transports.File({\n filename: options.filename,\n level: options.level ?? 'debug',\n format: format.combine(format.timestamp(), format.json()),\n }),\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAQ5E;AAED,eAAO,MAAM,MAAM,0BAOjB,CAAC;AAEH,UAAU,qBAAqB;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,qBAAqB,QAQ5D","sourcesContent":["import { format } from 'logform';\nimport { createLogger, transports } from 'winston';\n\n/**\n * Temporarily silence all logger output while executing the provided function.\n *\n * @param fn - The function to run with the logger silenced.\n * @returns The result of the function.\n */\nexport async function withoutLogging<T>(fn: () => T | Promise<T>): Promise<T> {\n const originalSilent = logger.silent;\n logger.silent = true;\n try {\n return await fn();\n } finally {\n logger.silent = originalSilent;\n }\n}\n\nexport const logger = createLogger({\n transports: [\n new transports.Console({\n level: 'info',\n format: format.combine(format.colorize(), format.simple()),\n }),\n ],\n});\n\ninterface AddFileLoggingOptions {\n filename: string;\n level?: string;\n}\n\nexport function addFileLogging(options: AddFileLoggingOptions) {\n logger.add(\n new transports.File({\n filename: options.filename,\n level: options.level ?? 'debug',\n format: format.combine(format.timestamp(), format.json()),\n }),\n );\n}\n"]}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import { format } from 'logform';
|
|
2
2
|
import { createLogger, transports } from 'winston';
|
|
3
|
+
/**
|
|
4
|
+
* Temporarily silence all logger output while executing the provided function.
|
|
5
|
+
*
|
|
6
|
+
* @param fn - The function to run with the logger silenced.
|
|
7
|
+
* @returns The result of the function.
|
|
8
|
+
*/
|
|
9
|
+
export async function withoutLogging(fn) {
|
|
10
|
+
const originalSilent = logger.silent;
|
|
11
|
+
logger.silent = true;
|
|
12
|
+
try {
|
|
13
|
+
return await fn();
|
|
14
|
+
}
|
|
15
|
+
finally {
|
|
16
|
+
logger.silent = originalSilent;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
3
19
|
export const logger = createLogger({
|
|
4
20
|
transports: [
|
|
5
21
|
new transports.Console({
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,CAAC,MAAM,MAAM,GAAG,YAAY,CAAC;IACjC,UAAU,EAAE;QACV,IAAI,UAAU,CAAC,OAAO,CAAC;YACrB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;SAC3D,CAAC;KACH;CACF,CAAC,CAAC;AAOH,MAAM,UAAU,cAAc,CAAC,OAA8B,EAAE;IAC7D,MAAM,CAAC,GAAG,CACR,IAAI,UAAU,CAAC,IAAI,CAAC;QAClB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,OAAO;QAC/B,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;KAC1D,CAAC,CACH,CAAC;AAAA,CACH","sourcesContent":["import { format } from 'logform';\nimport { createLogger, transports } from 'winston';\n\nexport const logger = createLogger({\n transports: [\n new transports.Console({\n level: 'info',\n format: format.combine(format.colorize(), format.simple()),\n }),\n ],\n});\n\ninterface AddFileLoggingOptions {\n filename: string;\n level?: string;\n}\n\nexport function addFileLogging(options: AddFileLoggingOptions) {\n logger.add(\n new transports.File({\n filename: options.filename,\n level: options.level ?? 'debug',\n format: format.combine(format.timestamp(), format.json()),\n }),\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAI,EAAwB,EAAc;IAC5E,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;IACrC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC;IACrB,IAAI,CAAC;QACH,OAAO,MAAM,EAAE,EAAE,CAAC;IACpB,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,MAAM,GAAG,cAAc,CAAC;IACjC,CAAC;AAAA,CACF;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,YAAY,CAAC;IACjC,UAAU,EAAE;QACV,IAAI,UAAU,CAAC,OAAO,CAAC;YACrB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;SAC3D,CAAC;KACH;CACF,CAAC,CAAC;AAOH,MAAM,UAAU,cAAc,CAAC,OAA8B,EAAE;IAC7D,MAAM,CAAC,GAAG,CACR,IAAI,UAAU,CAAC,IAAI,CAAC;QAClB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,OAAO;QAC/B,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;KAC1D,CAAC,CACH,CAAC;AAAA,CACH","sourcesContent":["import { format } from 'logform';\nimport { createLogger, transports } from 'winston';\n\n/**\n * Temporarily silence all logger output while executing the provided function.\n *\n * @param fn - The function to run with the logger silenced.\n * @returns The result of the function.\n */\nexport async function withoutLogging<T>(fn: () => T | Promise<T>): Promise<T> {\n const originalSilent = logger.silent;\n logger.silent = true;\n try {\n return await fn();\n } finally {\n logger.silent = originalSilent;\n }\n}\n\nexport const logger = createLogger({\n transports: [\n new transports.Console({\n level: 'info',\n format: format.combine(format.colorize(), format.simple()),\n }),\n ],\n});\n\ninterface AddFileLoggingOptions {\n filename: string;\n level?: string;\n}\n\nexport function addFileLogging(options: AddFileLoggingOptions) {\n logger.add(\n new transports.File({\n filename: options.filename,\n level: options.level ?? 'debug',\n format: format.combine(format.timestamp(), format.json()),\n }),\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prairielearn/logger",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"zod": "^3.25.76"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@prairielearn/tsconfig": "^
|
|
24
|
+
"@prairielearn/tsconfig": "^2.0.0",
|
|
25
25
|
"@types/node": "^24.10.9",
|
|
26
|
-
"@typescript/native-preview": "^7.0.0-dev.
|
|
26
|
+
"@typescript/native-preview": "^7.0.0-dev.20260203.1",
|
|
27
27
|
"typescript": "^5.9.3"
|
|
28
28
|
}
|
|
29
29
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import { format } from 'logform';
|
|
2
2
|
import { createLogger, transports } from 'winston';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Temporarily silence all logger output while executing the provided function.
|
|
6
|
+
*
|
|
7
|
+
* @param fn - The function to run with the logger silenced.
|
|
8
|
+
* @returns The result of the function.
|
|
9
|
+
*/
|
|
10
|
+
export async function withoutLogging<T>(fn: () => T | Promise<T>): Promise<T> {
|
|
11
|
+
const originalSilent = logger.silent;
|
|
12
|
+
logger.silent = true;
|
|
13
|
+
try {
|
|
14
|
+
return await fn();
|
|
15
|
+
} finally {
|
|
16
|
+
logger.silent = originalSilent;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
4
20
|
export const logger = createLogger({
|
|
5
21
|
transports: [
|
|
6
22
|
new transports.Console({
|