All Projects → samdenty → Console Feed

samdenty / Console Feed

Licence: mit
Captures console.log's into a React Component 🔥

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Console Feed

Node Build Monitor
A Build Monitor written in Node.js, which supports several build services and can be easily extended.
Stars: ✭ 336 (-0.3%)
Mutual labels:  hacktoberfest
Livecode
LiveCode cross-platform development environment (engine)
Stars: ✭ 336 (-0.3%)
Mutual labels:  hacktoberfest
Phpmussel
PHP-based anti-virus anti-trojan anti-malware solution.
Stars: ✭ 337 (+0%)
Mutual labels:  hacktoberfest
Pandas alive
Create stunning, animated visualisations with Pandas & Matplotlib as easy as calling `df.plot_animated()`
Stars: ✭ 333 (-1.19%)
Mutual labels:  hacktoberfest
Admin
A beautiful and fully-featured administration interface builder for hypermedia APIs
Stars: ✭ 335 (-0.59%)
Mutual labels:  hacktoberfest
Autostarter
This library helps bring up the autostart permission manager of a phone to the user so they can add an app to autostart.
Stars: ✭ 334 (-0.89%)
Mutual labels:  hacktoberfest
Pode
Pode is a Cross-Platform PowerShell web framework for creating REST APIs, Web Sites, and TCP/SMTP servers
Stars: ✭ 329 (-2.37%)
Mutual labels:  hacktoberfest
Youtube Api
📹 A Node.JS module, which provides an object oriented wrapper for the YouTube v3 API.
Stars: ✭ 338 (+0.3%)
Mutual labels:  hacktoberfest
Netcdf C
Official GitHub repository for netCDF-C libraries and utilities.
Stars: ✭ 336 (-0.3%)
Mutual labels:  hacktoberfest
Hexagon
Hexagon is a microservices toolkit written in Kotlin. Its purpose is to ease the building of services (Web applications, APIs or queue consumers) that run inside a cloud platform.
Stars: ✭ 336 (-0.3%)
Mutual labels:  hacktoberfest
Guark
Build awesome Golang desktop apps and beautiful interfaces with Vue.js, React.js, Framework 7, and more...
Stars: ✭ 334 (-0.89%)
Mutual labels:  hacktoberfest
Pact Python
Python version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
Stars: ✭ 335 (-0.59%)
Mutual labels:  hacktoberfest
Jotai
👻 Primitive and flexible state management for React
Stars: ✭ 6,453 (+1814.84%)
Mutual labels:  hacktoberfest
Stream
🗄️ Stream plugin for WordPress
Stars: ✭ 335 (-0.59%)
Mutual labels:  hacktoberfest
Portage
[MIRROR] Package management system
Stars: ✭ 336 (-0.3%)
Mutual labels:  hacktoberfest
Validator Docs
Validação de CPF, CNPJ, CNH, NIS, Título Eleitoral e Cartão Nacional de Saúde com Laravel.
Stars: ✭ 334 (-0.89%)
Mutual labels:  hacktoberfest
Trefle Api
🍀 Trefle is a botanical JSON REST API for plants species, allowing you to search and query over all the registered species, and build the next gardening apps and farming robots.
Stars: ✭ 335 (-0.59%)
Mutual labels:  hacktoberfest
Templates
Templates created by The Good Docs Project - for all your tech writing needs.
Stars: ✭ 334 (-0.89%)
Mutual labels:  hacktoberfest
Kotlin Telegram Bot
🤖 A wrapper for the Telegram Bot API written in Kotlin
Stars: ✭ 337 (+0%)
Mutual labels:  hacktoberfest
Parse Dashboard
A dashboard for managing your Parse Server Apps
Stars: ✭ 3,534 (+948.66%)
Mutual labels:  hacktoberfest

console-feed

npm version CircleCI npm downloads Demo

A React component that displays console logs from the current page, an iframe or transported across a server.

Demo

Who's using it

Features

  • Console formatting - style and give your logs color, and makes links clickable
  • DOM nodes - easily inspect & expand HTML elements, with syntax highlighting
  • console.table - view your logs in a table format
  • Other console methods:
    • console.time - view the time in milliseconds it takes to complete events
    • console.assert - assert that a statement is truthy
    • console.count - count how many times something occurs
  • Inbuilt JSON serialization - Objects, Functions & DOM elements can be encoded / decoded to and from JSON

Install

yarn add console-feed
# or
npm install console-feed

Basic usage

CodeSandbox

import React from 'react'
import { Hook, Console, Decode } from 'console-feed'

class App extends React.Component {
  state = {
    logs: [],
  }

  componentDidMount() {
    Hook(window.console, (log) => {
      this.setState(({ logs }) => ({ logs: [...logs, Decode(log)] }))
    })

    console.log(`Hello world!`)
  }

  render() {
    return (
      <div style={{ backgroundColor: '#242424' }}>
        <Console logs={this.state.logs} variant="dark" />
      </div>
    )
  }
}

OR with hooks:

import React, { useState, useEffect } from 'react'
import { Console, Hook, Unhook } from 'console-feed'

const LogsContainer = () => {
  const [logs, setLogs] = useState([])

  // run once!
  useEffect(() => {
    Hook(
      window.console,
      (log) => setLogs((currLogs) => [...currLogs, log]),
      false
    )
    return () => Unhook(window.console)
  }, [])

  return <Console logs={logs} variant="dark" />
}

export { LogsContainer }

Props for <Console /> component

logs: Log[]

An array consisting of Log objects. Required

filter?: Methods[]

Filter the logs, only displaying messages of certain methods.

variant?: 'light' | 'dark'

Sets the font color for the component. Default - light

styles?: Styles

Defines the custom styles to use on the component - see Styles.d.ts

searchKeywords?: string

A string value to filter logs

logFilter?: Function

If you want to use a custom log filter function, you can provide your own implementation

Log methods

Each log has a method assigned to it. The method is used to determine the style of the message and for the filter prop.

type Methods =
  | 'log'
  | 'debug'
  | 'info'
  | 'warn'
  | 'error'
  | 'table'
  | 'clear'
  | 'time'
  | 'timeEnd'
  | 'count'
  | 'assert'

Log object

A log object consists of the following:

type Logs = Log[]

interface Log {
  // The log method
  method: Methods
  // The arguments passed to console API
  data: any[]
}

Serialization

By default when you use the Hook() API, logs are serialized so that they will safely work with JSON.stringify. In order to restore a log back to format compatible with the <Console /> component, you need to call the Decode() method.

Disabling serialization

If the Hook function and the <Console /> component are on the same origin, you can disable serialization to increase performance.

Hook(
  window.console,
  (log) => {
    this.setState(({ logs }) => ({ logs: [...logs, log] }))
  },
  false
)

Developing

To run console-feed locally, simply run:

yarn
yarn start
yarn test:watch

Head over to http://localhost:3000 in your browser, and you'll see the demo page come up. After you make changes you'll need to reload, but the jest tests will automatically restart.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].