Skip to content

Commit

Permalink
Merge pull request #226 from fireproof-storage/fp_format
Browse files Browse the repository at this point in the history
FP_FORMAT for better log formatting
  • Loading branch information
jchris authored Sep 18, 2024
2 parents 709462c + 916abe3 commit 0d3f830
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ globalThis[Symbol.for("FP_PRESET_ENV")] = {
};
```
it's possible to change the logformat by setting FP_FORMAT to:
- jsonice makes the log output in multiline json
- yaml makes the log output in yaml
- json makes the log output in singleline json (default)
## Thanks 🙏
Fireproof is a synthesis of work done by people in the web community over the years. I couldn't even begin to name all the folks who made pivotal contributions. Without npm, React, and VS Code all this would have taken so much longer. Thanks to everyone who supported me getting into database development via Apache CouchDB, one of the original document databases. The distinguishing work on immutable data-structures comes from the years of consideration [IPFS](https://ipfs.tech), [IPLD](https://ipld.io), and the [Filecoin APIs](https://docs.filecoin.io) have enjoyed.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
},
"homepage": "https://github.com/fireproof-storage/fireproof#readme",
"dependencies": {
"@adviser/cement": "^0.2.24",
"@adviser/cement": "^0.2.27",
"@ipld/car": "^5.3.2",
"@ipld/dag-cbor": "^9.2.1",
"@ipld/dag-json": "^10.2.2",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
Env,
toCryptoRuntime,
CryptoRuntime,
JSONFormatter,
YAMLFormatter,
} from "@adviser/cement";
import { PathOps, StoreType, SuperThis, SuperThisOpts, TextEndeCoder } from "./types";
import { base58btc } from "multiformats/bases/base58";
Expand Down Expand Up @@ -195,6 +197,21 @@ export function ensureLogger(
(key, value) => {
// console.log("FP_DEBUG", key, value, debug)
switch (key) {
case "FP_FORMAT": {
switch (value) {
case "jsonice":
logger.SetFormatter(new JSONFormatter(logger.TxtEnDe(), 2));
break;
case "yaml":
logger.SetFormatter(new YAMLFormatter(logger.TxtEnDe(), 2));
break;
case "json":
default:
logger.SetFormatter(new JSONFormatter(logger.TxtEnDe()));
break;
}
break;
}
case "FP_DEBUG":
logger.SetDebug(value || []);
break;
Expand All @@ -203,6 +220,7 @@ export function ensureLogger(
break;
}
},
"FP_FORMAT",
"FP_DEBUG",
"FP_STACK",
);
Expand Down

0 comments on commit 0d3f830

Please sign in to comment.