react-loggly

1.0.3 • Public • Published

React Loggly Component

Easily log to loggly from inside your react application.

Getting Started

Install React-Loggly using npm:

npm install --save react-loggly

At the top of your application, or at the top of the tree where you want to do your logging, add ReactLoggly

import ReactLoggly from 'react-loggly';
...
render(){
    return (
        <ReactLoggly
            token={this.state.token}
        >
         <App>
        </ReactLoggly>
    );
}

Then in each component you want to log from, accept the context type: logger

class MyComponent extends React.Component{
  static contextTypes = {
    logger: PropTypes.func,
  };
 
  render(){
    return (
        <button onClick={() => {
           this.context.logger("Logging from my component");
        }}
        >
            Log
        </button>
    );
  }
}

Props

  • token: Loggly API token
  • logFromConsole: When true, capture console output and send it to loggly
  • logToConsole: When true, echo all log messages sent to loggly to the console too
  • tags: Array of tags to log with the message.

Log(data)

Expects data to be a string or an object, which will be send to loggly.

Readme

Keywords

none

Package Sidebar

Install

npm i react-loggly

Weekly Downloads

3

Version

1.0.3

License

MIT

Unpacked Size

76.6 kB

Total Files

12

Last publish

Collaborators

  • irvined