Skip to content

tshelburne/cycle-log-driver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cycle-log-driver

CircleCI

Logging driver for CycleJS that enables simple client-side log.

Usage

npm install --save cycle-log-driver

Big picture, the log driver consumes a stream of shapes {name, (message|messages), color?}, and creates a nice log in the console to review those items after they've passed through the stream. The log driver creation function also takes a configuration for log output to include, making it much easier to change logging depending on the environment (for instance, not logging in production).

import {run} from '@cycle/run'
import makeLogDriver from 'cycle-log-driver'

function main(sources) {
	return {
		// other stuff...,
		log: xs.merge(
			props_.map(props => ({name: `state`, message: props, color: `#4286f4`})),
			event_.map(event => ({name: `action`, message: event, color: `#4cc456`})),
			request_.map(({url, method}) => ({
				name: `request`,
				message: `${method} ${url}`,
				color: `#cca23b`,
			})),
			sources.http.select().flatten().map(({request, status, body}) => ({
				name: `response`,
				messages: [`${request.method} ${request.url}`, status, body],
				color: `#f94f31`,
			}))
		),
	}
}

run(main, {
	// other stuff...,
	log: makeLogDriver({include: [`state`, `action`, `request`, `response`]}),
})

About

A simple logging driver for CycleJS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published