GithubHelp home page GithubHelp logo

Comments (6)

guigrpa avatar guigrpa commented on June 23, 2024

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.

guigrpa avatar guigrpa commented on June 23, 2024

Closing this now. Please reopen if the solution is not sufficient

from storyboard.

guigrpa avatar guigrpa commented on June 23, 2024

Included the logger tool in the library, under lib/stdinLogger.js (src: src/stdinLogger.coffee).

from storyboard.

TotallyInformation avatar TotallyInformation commented on June 23, 2024

Thanks.

from storyboard.

guigrpa avatar guigrpa commented on June 23, 2024

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.

TotallyInformation avatar TotallyInformation commented on June 23, 2024

Thanks Guillermo, I'll check it out.

from storyboard.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.