zakodium-oss / react-science

React components and tools to build scientific applications.
https://react-science.pages.dev
MIT License
2 stars 6 forks source link

feat: add logger components #709

Closed stropitek closed 5 months ago

stropitek commented 6 months ago

Closes: https://github.com/zakodium-oss/react-science/issues/449

cloudflare-workers-and-pages[bot] commented 6 months ago

Deploying react-science with  Cloudflare Pages  Cloudflare Pages

Latest commit: 26ad88f
Status: ✅  Deploy successful!
Preview URL: https://fcda01ba.react-science.pages.dev
Branch Preview URL: https://449-new-modal-for-logs-logge.react-science.pages.dev

View logs

stropitek commented 6 months ago

Usage:

import { FifoLogger } from 'fifo-logger';
const fifoLogger = new FifoLogger();

function App() {
  return (
    <FifoLoggerProvider logger={fifoLogger}>
      // ...
      <FifoLoggerToolbarItem />
    </FifoLoggerProvider>
  );
}

To add logs:

function ComponentAddingLogs() {
  const logger = useFifoLogger();

  // In callback / useEffect
  logger.info('info');
}

To get render something when the logs are updated:

function ComponentThatNeedsLogs() {
  const logs = useFifoLogs();
}
stropitek commented 5 months ago

@lpatiny This PR is awaiting your review

@moonayyur can you have a look as well? Because you designed a similar component in pixelium and the goal is to replace it with this one.