Comments (6)
In Linux/Raspbian, you can pipe the output of your program to a simple logger.js
script as follows:
$ ./myProgram |& node logger
(using |&
to connect both stdout
and stderr
to the logger). And in logger.js
:
var split = require('split');
var mainStory = require('storyboard').mainStory;
process.stdin.pipe(split())
.on('data', function(line) { mainStory.info(line); })
.on('end', function() { process.exit(0); });
I'm using here the split package to read stdin
line by line and pass it to Storyboard's mainStory
for logging. You may want to parse the input line to determine its level (whether it should be written as debug
, info
, warn
, error
, etc.) and source, which would be useful for filtering.
Example output:
$ ls |& node logger
2016-04-22T05:43:23.238Z storyboard INFO ┌── ROOT STORY: Node.js 5.4.1 on Linux 64-bit [CREATED]
2016-04-22T05:43:23.249Z main INFO logger.js
2016-04-22T05:43:23.250Z main INFO node_modules
2016-04-22T05:43:23.250Z main INFO package.json
2016-04-22T05:43:23.250Z main INFO src
2016-04-22T05:43:23.250Z main INFO test
2016-04-22T05:43:23.251Z main INFO
2016-04-22T05:43:23.252Z storyboard INFO └── ROOT STORY: Node.js 5.4.1 on Linux 64-bit [CLOSED]
$ missingCommand |& node logger
2016-04-22T05:43:37.035Z storyboard INFO ┌── ROOT STORY: Node.js 5.4.1 on Linux 64-bit [CREATED]
2016-04-22T05:43:37.046Z main INFO missingCommand: command not found
2016-04-22T05:43:37.048Z main INFO
2016-04-22T05:43:37.048Z storyboard INFO └── ROOT STORY: Node.js 5.4.1 on Linux 64-bit [CLOSED]
Please tell me if it works for you!
from storyboard.
Closing this now. Please reopen if the solution is not sufficient
from storyboard.
Included the logger tool in the library, under lib/stdinLogger.js
(src: src/stdinLogger.coffee
).
from storyboard.
Thanks.
from storyboard.
Just FYI, Storyboard version 2.0 includes a revamped CLI tool that handles not only stdout
, but also stderr
and stdin
. In fact, you can even wrap a whole shell like this: sb --server sh
.
from storyboard.
Thanks Guillermo, I'll check it out.
from storyboard.
Related Issues (15)
- Display login errors
- Parsing error: Unexpected token : HOT 6
- Recieving logs by another websocket client HOT 5
- listenerCreate is not a function HOT 2
- Postgres schema HOT 1
- Default src HOT 5
- Forget items from leaves of tree upwards HOT 2
- Demo is down. HOT 3
- Change port HOT 1
- Typescript types HOT 2
- Add levels to stories HOT 1
- Heroku app is down HOT 3
- DevTools extensions for chrome mobile ? HOT 5
- Trying to get in touch regarding a security issue HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from storyboard.