oarevalo / BugLogHQ

BugLogHQ is a tool to centralize the handling of automated bug reports from multiple applications. BugLogHQ provides a unified view of error messages sent from any number of applications, allowing the developer to search, graph, forward, and explore the bug reports submitted by the applications.
http://www.bugloghq.com
154 stars 67 forks source link

No matching Method/Function for Number.logEntry #140

Closed ivanionut closed 8 years ago

ivanionut commented 8 years ago

Hi, I downloaded the latest version from github, I configured the buglog-config.xml.cfm files, I created the db and I entered in the admin area (/bugLog/hq/?event=admin.main). Everything works until now.

I added:

    try {

        …bla bla bla…

    // In caso di errore
    } catch( Any e ){

        // writeDump( e );

        // Registro l'errore dentro bugLogHQ
        var bl = createObject("component", "bugLog.client.bugLogService");
        bl.notifyService(e.message, e);

    }

I intentionally caused an error in my app (to see if bugLog works), but I get this error:

No matching Method/Function for Number.logEntry

What can it be?

oarevalo commented 8 years ago

I think the problem is because it is missing the init method call after the createObject

ivanionut commented 8 years ago

Hi Oscar, How should I set it to initialize? This way gives me blank page when an error occurs.

var bl = createObject("component", "bugLog.client.bugLogService").init("/bugLog/listeners/listener.cfc");
        bl.notifyService(e.message, e);

Thanks, Ivan

oarevalo commented 8 years ago

The listener argument to the init method needs to be a full URL. For example:

var bl = createObject("component", "bugLog.client.bugLogService")
                .init("http://localhost/bugLog/listeners/listener.cfc");
bl.notifyService(e.message, e);

Replace http://localhost/ with whatever is appropriate for your setup.

Oscar

ivanionut commented 8 years ago

Ok, but now I get this error: Error2

ivanionut commented 8 years ago

The problem is that the website is https I modified in this bugLogService.cfc manner:


    variables.protocol = "CFC";

Now BugLogHQ does not give me any error. But it does not log application error...

ivanionut commented 8 years ago

No idea on how to solve this problem?

oarevalo commented 8 years ago

Hey Ivan, The idea of BugLogHQ is that it will typically be called from "the outside". So, several applications could be running the BugLogHQ client component, all pointing to a single central BugLogHQ server. Then anytime there is an error on any of the applications or servers, they will all be aggregated together.

Therefore the "listener" argument to the the bugLog.client.bugLogService instance should be any URL on which the BugLog server can be accessed from the outside.

For example, if you are running on your local server, this could be:

http://localhost/bugLog/listeners/listener.cfc

or if you want to reach a server that has a full domain and https enabled:

https://my.domain.com/bugLog/listeners/listener.cfc

Now, there is also another way in which you can access BugLog, but this can only be used when the BugLog server and the monitored application are running in the same ColdFusion instance. In that case you use the CFC protocol. When you use this mode, the listener address should now be the fully qualified cfc path to the listener.cfc component.

For example:

bugLog.listeners.listener

Basically this would be the argument used on a createObject statement to create an instance of the listener object.

Hopefully this clarifies your situation a bit.

ivanionut commented 8 years ago

Ok. Now everything is much clearer.

Now I have tried so:

    try {

            // another code

    } catch( Any e ){

        var bl = createObject("component", "bugLog.client.bugLogService").init("bugLog.listeners.listener");
        bl.notifyService(e.message, e);

    }

but I get this other error: variable [SERVICELOADER] doesn't exist error3

oarevalo commented 8 years ago

Do you have the strict var scoping enabled? I'm thinking that this may be due to a missing var statement here: https://github.com/oarevalo/BugLogHQ/blob/master/listeners/listener.cfc#L7

Can you try adding the missing var to that line and test again? I'll be making a patch shortly.

ivanionut commented 8 years ago

I tried:

<cfset var serviceLoader = createObject("component", "bugLog.components.service").init( instanceName = variables.instanceName )/>

but the error always remains the same as before.

This is Lucee Settings - Scope scope

oarevalo commented 8 years ago

Meaning that you still get the "serviceLoader doesn't exist' error?

oarevalo commented 8 years ago

oh no, silly me. I gave you the wrong suggestion. The correct line should be:

 <cfset variables.serviceLoader = createObject("component", "bugLog.components.service").init( instanceName = variables.instanceName )/>

By using var it becomes a local variable to the init() function. What we need is to make it an instance variable.

ivanionut commented 8 years ago
<cfset variables.serviceLoader = createObject("component", "bugLog.components.service").init( instanceName = variables.instanceName )/>

same error: variable [SERVICELOADER] doesn't exist

oarevalo commented 8 years ago

That's weird. Maybe you can drop a cfdump / cfabort right after the createObject line to dump the serviceLoader object and make sure it is being created. Not sure what else it could be.

ivanionut commented 8 years ago

neither dump / abort does not work ... I included this but the page do not show the dump. It only displays the error first (variable [SERVICELOADER] doesn't exist)

it is as if he ignoring the init() function...

    <cffunction name="init" access="public" returntype="listener">
        <cfargument name="instanceName" type="string" required="true">
        <cfset variables.instanceName = arguments.instanceName>

    <cfset variables.serviceLoader = createObject("component", "bugLog.components.service").init( instanceName = variables.instanceName )/>

    <cfscript>
        return writeDump(variables.serviceLoader);
        abort;
    </cfscript>

        <cfreturn this>
    </cffunction>
oarevalo commented 8 years ago

you could try without the return. just do:

<cfdump var="#variables.serviceLoader#">
<cfabort>
ivanionut commented 8 years ago

Nothing. Does not show the dump...

    <cffunction name="init" access="public" returntype="listener">
        <cfargument name="instanceName" type="string" required="true">
        <cfset variables.instanceName = arguments.instanceName>
        <cfset variables.serviceLoader = createObject("component", "bugLog.components.service").init( instanceName = variables.instanceName )/>

        <cfdump var="#variables.serviceLoader#">
        <cfabort>
    </cffunction>
oarevalo commented 8 years ago

Ok I think i finally understand what is happening. When you use the CFC protocol, the listener instance is created by the client, but the init() method is never called. Therefore the serviceLoader is never initialized (and that's also why you don't see the abort/dump). The serviceLoader is relatively recent addition to BugLog and since the CFC protocol is very rarely used, that may explain why it was overlooked.

There is a couple of things you can do short term.

  1. Add a call to .init() in the BugLog client service when the listener CFC is instantiated. The argument is the instance name. Try empty string, and if that doesnt work or throws an error, use default
  2. Use the SOAP or REST listeners using the externally accessible URL to your BugLog server, as explained above.
ivanionut commented 8 years ago

Ok. Now I try to move BugLogHQ in a subdomain "bugs.website.it". After I inform you if I have solved.

ivanionut commented 8 years ago

1) I created a neat installation inside the subdomain bugs.webiste.it/bugLog/

In bugLog page admin webpage:

BugLogListener Service is: Stopped

When I click on start:

Error! invalid component definition, can't find component [listener]

2) on production web site I just saved the component ’bugLogService.cfc’

try {
    …

    } catch( Any e ){

        var bl = createObject("component", "components.bugLogService").init("http://bugs.website.it/bugLog/listeners/bugLogListenerREST.cfm");
        bl.notifyService(e.message, e);

    }

3) On the production site when emulating an error: error

ivanionut commented 8 years ago

you gave up? :laughing:

Now if I click on "start": invalid component definition, can't find component [components.bugLogListenerAsync] (I have not made any changes)

oarevalo commented 8 years ago

Hey Ivan, sorry for the delay. Can you try accessing "http://bugs.website.it/bugLog/listeners/bugLogListenerREST.cfm" on your browser or via curl? See if you get an error, or some kind of response.

ivanionut commented 8 years ago

eer

oarevalo commented 8 years ago

On your config file (/bugLog/config-config.xml.cfm) what is the value of service.serviceCFC ? Also, do you have buglog installed in a directory named bugLog in your webroot?

ivanionut commented 8 years ago

I have now set up well: <setting name="service.serviceCFC">bugLog.components.bugLogListenerAsync</setting>

Do you believe if I tell you right now work? :satisfied: :satisfied:

You were very kind and very helpful! Thank you so much for the help! :+1:

oarevalo commented 8 years ago

Yay! :)

I'm glad it's working now. Feel free to open a new ticket here if you run into any more issues, or have any questions.

Thanks for trying out BugLogHQ!