Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@krismuniz/console-feed
Advanced tools
A React component that displays console logs from the current page, an iframe or transported across a server
@krismuniz/console-feed
NOTE: While this is a fork of samdenty/console-feed it will not be compatible with the original project and will likely diverge. Please consider using the original module instead.
A React component that displays console logs from the current page, an iframe or transported across a server.
console.table
- view your logs in a table formatconsole.time
- view the time in milliseconds it takes to complete eventsconsole.assert
- assert that a statement is truthyconsole.count
- count how many times something occursyarn add console-feed
# or
npm install console-feed
import React from 'react'
import { Hook, Console, Decode } from '@krismuniz/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 '@krismuniz/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 }
<Console />
componentlogs: 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
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
objectA log object consists of the following:
type Logs = Log[]
interface Log {
// The log method
method: Methods
// The arguments passed to console API
data: any[]
}
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.
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
)
You can limit the number of keys/elements included when serializing objects/arrays.
Hook(
window.console,
(log) => {
this.setState(({ logs }) => ({ logs: [...logs, log] }))
},
true,
100 // limit to 100 keys/elements
)
FAQs
A React component that displays console logs from the current page, an iframe or transported across a server
We found that @krismuniz/console-feed demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.