open-index/open-npm huggingface dataset:
npm package: @fict/logger
Description: The logging utility package for Fict
Latest version: 0.1.3

# How to use @fict/logger
`@fict/logger` allows multiple modules to use a logger at the same time. From each of the modules initialize it as below:
```js
const logger = require('@fict/logger').defaultInit('../package.json', { logConfigFolder: __dirname + "/../../config/logger" });
```
In the `package.json` you can set custom property `logLabel` to any value that you want to show in the logs as the name of the module. If not set, the name of the package will be used by default.

The logger created above is a child object that comes in-built with `{src: logLabel}` context for the log. To use the logger just use any of the `info`, `debug`, `warn` or `log` methods as usual:
```js
  app.logger.info(`Server started at ${host}:${port}`)
```

To add any additional context, use it as below:
```js
  app.logger.info({additionalCtx: value}, `Server started at ${host}:${port}`)
```
npm package: @fict/semantic-model
Description: The Semantic Model package for Fict Ledger
Latest version: 0.3.3

# How to use @fict/semantic-model
Below is an example usage:
```js
const fs = require("fs");
const os = require("os");
const path = require("path");
const { init, Generator } = require("@fict/semantic-model");

function test() {
  const ctoModelStr = fs.readFileSync(path.resolve(__dirname, "product.cto"), "utf8");
  
  const gen = new Generator();
  gen.addCTOModel(ctoModelStr, "product.cto", true); // add more models if needed

  const opts = { destFolder: os.tmpdir(), forceOverwrite: false };
  return Promise.all([
    gen.generateJSFiles(opts),    // generate JS files
    gen.generateMermaidFile(opts), // generate mermaid diagram
    gen.generateJSONSchema(), // generates JSONSchema string
  ]);
}

init().then(test).catch(console.error);
```

To specify a custom `logger`, see the example code in the [test](./test) folder.