mperdeck / jsnlog.js

Tiny JavaScript logging library, simple and well documented. Lots of options to filter logging data.
js.jsnlog.com
Other
130 stars 44 forks source link

JSNLog Not resetting xhr object in React native #75

Open msreddy09 opened 4 years ago

msreddy09 commented 4 years ago

I have written code as below in react native. But I am seeing only one message(very first message) in the server.

Any consecutive requesting fails with [Error: Cannot open, already sending]

import {JL} from 'jsnlog'

 var app = JL.createAjaxAppender("appender").setOptions({     
     'url': 'http://127.0.0.1:8080/log'
 });

 JL().setOptions({
     "appenders": [app]
 });

class App extends React.Component {
    componentDidMount () {
      JL().info('Application started')
      JL()..debug('Application started with no config')
    }
    render() {
        return(
            <div className ="container-fluid">
               <Header />
               <Switch>
                    <Route exact path ="/" component ={HomePage} />
                    <Route  path ="/about" component ={AboutPage} />
                    <Route  path ="/courses" component ={CoursesPage} />
                    <Route  component={PageNotFound} />
               </Switch>

            </div>
        )
    }
}

export default App;

Temporarily, we tried re-initialized XHR object inside the


  AjaxAppender.prototype.sendLogItemsAjax = function (logItems, successCallback) {

        this.xhr = JL._createXMLHttpRequest()
    // rest of the code
}```
bogdandoi commented 3 years ago

I encountered the same issue on a react-native app. will there be a fix for this?

mperdeck commented 3 years ago

I am not familiar with React Native, so not really in a position to investigate this. But if you could send me a pull request with a fix, that would be great.

bogdanicis commented 3 years ago

I've created a feature branch with the fix but I'm not authorized to push it. @mperdeck can you give me access for this?

mperdeck commented 3 years ago

Did you try to push to my repo directly, or create a pull request?

Creating a pull request would be the way to go. To do that, you'd first create a fork, make your updates on the fork, then create the pull request to get the changes into my repo.

See https://guides.github.com/activities/forking/

bogdanicis commented 3 years ago

I created the PR: https://github.com/mperdeck/jsnlog.js/pull/77. @mperdeck , please take a look when you have the time