From 2f675ee5fc2396129c286a000d0178cf66b9f0e8 Mon Sep 17 00:00:00 2001 From: Doug Wade Date: Tue, 24 May 2016 21:29:43 -0700 Subject: [PATCH] Add logger to yeoman generator --- .../generators/app/templates/hello-world.js | 4 ++++ .../generators/app/templates/package.json | 1 + packages/generator-react-server/package.json | 5 ++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/generator-react-server/generators/app/templates/hello-world.js b/packages/generator-react-server/generators/app/templates/hello-world.js index 9bf38e2c6..ffee4fcd9 100644 --- a/packages/generator-react-server/generators/app/templates/hello-world.js +++ b/packages/generator-react-server/generators/app/templates/hello-world.js @@ -1,10 +1,14 @@ import React from 'react'; +import {logging} from 'react-server'; + +const logger = logging.getLogger(__LOGGER__); export default class HelloWorld extends React.Component { constructor(props) { super(props); this.state = {exclamationCount: 0}; this.handleClick = () => { + logger.info(`Getting more excited! previously ${this.state.exclamationCount} excitements.`); this.setState({exclamationCount: this.state.exclamationCount + 1}); }; } diff --git a/packages/generator-react-server/generators/app/templates/package.json b/packages/generator-react-server/generators/app/templates/package.json index b90a92953..02ab2144f 100644 --- a/packages/generator-react-server/generators/app/templates/package.json +++ b/packages/generator-react-server/generators/app/templates/package.json @@ -28,6 +28,7 @@ "xo": { "esnext": true, "extends": "xo-react", + "globals": ["__LOGGER__"], "ignores": ["__clientTemp/**/*"] } } diff --git a/packages/generator-react-server/package.json b/packages/generator-react-server/package.json index 0932d677b..907c8c395 100644 --- a/packages/generator-react-server/package.json +++ b/packages/generator-react-server/package.json @@ -38,12 +38,11 @@ }, "license": "Apache-2.0", "xo": { + "envs": ["node"], "extends": "xo-react", + "globals": ["__LOGGER__"], "ignores": [ "test/**/*" - ], - "envs": [ - "node" ] } }