https://github.com/cheminfo/fifo-logger

https://github.com/cheminfo/fifo-logger

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.1%) to scientific vocabulary

Keywords from Contributors

nmr nmr-spectroscopy bruker jcamp jcamp-dx jeol nmr-parser
Last synced: 11 months ago · JSON representation

Repository

Basic Info
Statistics
  • Stars: 0
  • Watchers: 4
  • Forks: 1
  • Open Issues: 1
  • Releases: 16
Created over 3 years ago · Last pushed about 1 year ago
Metadata Files
Readme Changelog License

README.md

fifo-logger

NPM version npm download test coverage license

Simple event logger for the browser and Node.js inspired by pino.

By default, it will keep the 10'000 last events that can easily be retrieved and filtered.

Installation

console npm install fifo-logger

Simple usage

```js import { FifoLogger } from 'fifo-logger';

const logger = new FifoLogger({ limit: 1000, // default value level: 'info', // by default we will not log the level under 'info' (trace and debug) });

logger.trace('a trace'); logger.debug('a debug'); logger.info('an info'); logger.warn('a warning'); logger.error('a error'); logger.fatal('fatal');

// you have also the possibility to log an object or object + message

logger.warn({ a: 1, b: 2, c: 'Hello' }, 'a warning');

// errors can also be directly added to the logger

logger.fatal(new Error('a fatal error'));

// to get the logs

const logs = logger.getLogs(); ```

Logging in a specific context

A child logger may be created in order to store specific related logs. Each logger or child logger will receive a specific UUID.

```js import { FifoLogger } from 'fifo-logger';

const logger = new FifoLogger(); logger.info('an info');

const childLogger = logger.child(); childLogger.info('from child');

const grandChildLogger = childLogger.child(); grandChildLogger.info('from grandchild');

const anotherLogger = logger.child(); anotherLogger.info('from another child');

console.log(logger.getLogs()); // 1 element console.log(logger.getLogs({ includeChildren: true })); // 4 elements console.log(childLogger.getLogs()); // 1 element console.log(childLogger.getLogs({ includeChildren: true })); // 3 elements ```

Callback when new logs are added

If you need to update the log list based on new addition you can add the onChange callback

```js const logger = new FifoLogger({ onChange: (log, logs, info) => { console.log(log, logs, info); }, }); logger.info('Hello world');

// info contains 'depth' starting at 1 ```

Callback with throttling

Libraries may be quite verbose and you can throttle the callback using such a code

```js import { throttle } from 'throttle-debounce';

import { FifoLogger } from 'fifo-logger';

let results: any = [];

let throttleFunc = throttle(100, (log, logs) => { results.push(log.message); results.push(logs.length); });

const logger = new FifoLogger({ onChange: throttleFunc, });

logger.info('first info'); logger.info('second info');

const start = Date.now(); while (Date.now() - start < 120);

logger.info('an info after 120ms');

console.log(results); // ['first info', 1, 'an info after 120ms', 3] ```

In the browser

``html <html> <head> <script src="https://www.lactame.com/lib/fifo-logger/0.3.0/fifo-logger.js" type="text/javascript" ></script> <script Logger="fifo-logger" type="text/javascript"> const logger = new FifoLogger.FifoLogger({ onChange: (log, logs) => { console.log(logs); document.getElementById('logs').innerHTML = '<table><tr><th>Level</th><th>Message</th></tr>' + logs .map((log) => { return${log.level}${log.message}`; }) .join('') + ''; }, });

<script>
  logger.info('Hello World!');
  logger.error('This is an error');
</script>

```

License

MIT

Owner

  • Name: Cheminfo
  • Login: cheminfo
  • Kind: organization

GitHub Events

Total
  • Release event: 1
  • Delete event: 1
  • Issue comment event: 5
  • Push event: 4
  • Pull request review event: 2
  • Pull request review comment event: 2
  • Pull request event: 6
  • Create event: 2
Last Year
  • Release event: 1
  • Delete event: 1
  • Issue comment event: 5
  • Push event: 4
  • Pull request review event: 2
  • Pull request review comment event: 2
  • Pull request event: 6
  • Create event: 2

Committers

Last synced: over 3 years ago

All Time
  • Total Commits: 47
  • Total Committers: 4
  • Avg Commits per committer: 11.75
  • Development Distribution Score (DDS): 0.34
Top Committers
Name Email Commits
Luc Patiny l****c@p****m 31
cheminfo-bot 1****t@u****m 12
Luc Patiny l****y@u****m 3
hamed-musallam 3****m@u****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 5
  • Total pull requests: 22
  • Average time to close issues: 18 days
  • Average time to close pull requests: 3 days
  • Total issue authors: 3
  • Total pull request authors: 5
  • Average comments per issue: 0.8
  • Average comments per pull request: 1.45
  • Merged pull requests: 21
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 2
  • Average time to close issues: N/A
  • Average time to close pull requests: 2 minutes
  • Issue authors: 1
  • Pull request authors: 1
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • lpatiny (3)
  • hamed-musallam (1)
  • kleinron (1)
Pull Request Authors
  • cheminfo-bot (18)
  • lpatiny (9)
  • stropitek (2)
  • targos (1)
  • hamed-musallam (1)
Top Labels
Issue Labels
Pull Request Labels
autorelease: tagged (14) autorelease: pending (4)

Packages

  • Total packages: 1
  • Total downloads:
    • npm 2,923 last-month
  • Total dependent packages: 9
  • Total dependent repositories: 1
  • Total versions: 16
  • Total maintainers: 1
npmjs.org: fifo-logger

Simple event logger for the browser and node.js

  • Versions: 16
  • Dependent Packages: 9
  • Dependent Repositories: 1
  • Downloads: 2,923 Last month
Rankings
Dependent packages count: 2.3%
Downloads: 3.2%
Average: 9.7%
Dependent repos count: 10.3%
Forks count: 11.6%
Stargazers count: 21.0%
Maintainers (1)
Last synced: 11 months ago

Dependencies

.github/workflows/lactame.yml actions
  • actions/checkout v4 composite
  • actions/setup-node v4 composite
  • zakodium/lactame-action v1 composite
.github/workflows/nodejs-ts.yml actions
.github/workflows/release.yml actions
.github/workflows/typedoc.yml actions
  • JamesIves/github-pages-deploy-action releases/v4 composite
  • actions/checkout v4 composite
  • actions/setup-node v4 composite
  • zakodium/typedoc-action v2 composite
package.json npm
  • @babel/plugin-transform-modules-commonjs ^7.23.3 development
  • @babel/preset-typescript ^7.23.3 development
  • @types/jest ^29.5.11 development
  • @types/throttle-debounce ^5.0.2 development
  • cheminfo-build ^1.2.0 development
  • eslint ^8.56.0 development
  • eslint-config-cheminfo-typescript ^12.1.0 development
  • jest ^29.7.0 development
  • pino ^8.17.1 development
  • prettier ^3.1.1 development
  • rimraf ^5.0.5 development
  • throttle-debounce ^5.0.0 development
  • typescript ^5.3.3 development
  • @lukeed/uuid ^2.0.1