You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@guacamole.apache.org by ErinVersfeld <er...@gmail.com> on 2017/10/30 07:19:43 UTC

Console.log messages not included post minification

I'm new to Guacamole, and am trying to adapt the base client for a project
I'm working on. However, I'm having trouble with getting my console.log
message to be included in the minified JavaScript. I'm assuming that it's
the minification process that's removing them, because the logs are in the
source code on my machine, but I can't work out where  the minification is
happening. Do you perhaps have any advice for me?

I'm trying to use the logs to work out why my modified version of the client
isn't displaying HTTP error messages, even though they're coming through to
it. I've also tried using dummy variable to track a similar thing, but I
can't get that working either. I'm using tomcat 7 and Xtightvnc.




--
Sent from: http://apache-guacamole-incubating-users.2363388.n4.nabble.com/

RE: Console.log messages not included post minification

Posted by Ryan Underwood <ry...@greymarketlabs.com>.
Can't help you with the logging but the minification itself happens as part of the maven build of incubator-guacamole-client\guacamole. Relevant excerpt from pom.xml:

           <!-- JS/CSS Minification Plugin -->
            <plugin>
                <groupId>com.samaxes.maven</groupId>
                <artifactId>minify-maven-plugin</artifactId>
                <version>1.7.5</version>
                <executions>
                    <execution>
                        <id>default-cli</id>
                        <configuration>
                            <charset>UTF-8</charset>

                            <webappSourceDir>${project.build.directory}/${project.build.finalName}</webappSourceDir>

                            <cssSourceDir>/</cssSourceDir>
                            <cssTargetDir>/</cssTargetDir>
                            <cssFinalFile>guacamole.css</cssFinalFile>

                            <cssSourceFiles>
                                <cssSourceFile>license.txt</cssSourceFile>
                            </cssSourceFiles>
                            
                            <cssSourceIncludes>
                                <cssSourceInclude>app/**/*.css</cssSourceInclude>
                            </cssSourceIncludes>

                            <jsSourceDir>/</jsSourceDir>
                            <jsTargetDir>/</jsTargetDir>
                            <jsFinalFile>guacamole.js</jsFinalFile>
                            
                            <jsSourceFiles>
                                <jsSourceFile>license.txt</jsSourceFile>
                                <jsSourceFile>guacamole-common-js/all.js</jsSourceFile>
                            </jsSourceFiles>

                            <jsSourceIncludes>
                                <jsSourceInclude>app/**/*.js</jsSourceInclude>
                                <jsSourceInclude>generated/**/*.js</jsSourceInclude>
                            </jsSourceIncludes>

                            <!-- Do not minify and include tests -->
                            <jsSourceExcludes>
                                <jsSourceExclude>**/*.test.js</jsSourceExclude>
                            </jsSourceExcludes>
                            <jsEngine>CLOSURE</jsEngine>

                            <!-- Disable warnings for JSDoc annotations -->
                            <closureWarningLevels>
                                <misplacedTypeAnnotation>OFF</misplacedTypeAnnotation>
                                <nonStandardJsDocs>OFF</nonStandardJsDocs>
                            </closureWarningLevels>

                        </configuration>
                        <goals>
                            <goal>minify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

-----Original Message-----
From: ErinVersfeld [mailto:erinversfeld@gmail.com] 
Sent: Monday, October 30, 2017 3:20 AM
To: user@guacamole.incubator.apache.org
Subject: Console.log messages not included post minification

I'm new to Guacamole, and am trying to adapt the base client for a project I'm working on. However, I'm having trouble with getting my console.log message to be included in the minified JavaScript. I'm assuming that it's the minification process that's removing them, because the logs are in the source code on my machine, but I can't work out where  the minification is happening. Do you perhaps have any advice for me?

I'm trying to use the logs to work out why my modified version of the client isn't displaying HTTP error messages, even though they're coming through to it. I've also tried using dummy variable to track a similar thing, but I can't get that working either. I'm using tomcat 7 and Xtightvnc.




--
Sent from: http://apache-guacamole-incubating-users.2363388.n4.nabble.com/

Re: Console.log messages not included post minification

Posted by Erin Versfeld <er...@gmail.com>.
Great, thanks for that! The only modification I've made really is to swap
out the authentication plug-in, and then modify some css here and there.
All of the HTTP errors are just returning blank pages.

On Wed, Nov 1, 2017 at 3:31 PM, Nick Couchman <vn...@apache.org> wrote:

>
>
> On Wed, Nov 1, 2017 at 9:01 AM, Erin Versfeld <er...@gmail.com>
> wrote:
>
>> Thanks, Ryan and Nick,
>>
>> I've played around with all the log settings in the browser console, and
>> run my app on multiple browsers, so that at least can be rules out as an
>> issue for now.
>>
>> Looking more closely at minify-maven, one of the tools its built on top
>> of is Google's Closure Compiler, which "parses your JavaScript, analyzes
>> it, removes dead code and rewrites and minimizes what's left", which could
>> potentially explain this behaviour. Commenting out that whole process from
>> the pom file then breaks things because app.js isn't build. I'm playing
>> around with changing the index.html and seeing if just pointing it to the
>> individual .js files works, but alternative suggestions are also welcome.
>>
>> I tried injecting the $log service, but had no luck. It's entirely
>> possible that I wasn't doing it correctly, though, so I'm heading back to
>> the docs to confirm that.
>>
>
> In the file where you want to use it, simply find the sections toward the
> top of the file that have one or more $injector.get lines, and add the
> following:
>
> var $log = $injector.get('$log');
>
> Then elsewhere in your code use $log.debug('Your debug message here.') to
> get the output (or $log.info(), $log.warn(), $log.error()).
>
> It's also possible that the lines of code where you're attempting to put
> log statements aren't actually being reached, so make sure you're putting
> those statements in places that you absolutely know are executing.
>
>
>
>>
>> I am modifying the client rather than using the API portions of the
>> client code to write a custom app. The kinds of errors I expect to see are
>> the stock standard HTTP errors, like 404s, 500s, etc. I'd just like to have
>> a little pop up or display a relevant error message when these errors
>> occur. The browser is able to tell which of these errors has occurred, so
>> it looks like everything is working as expected, its just handling this on
>> the client side which is proving irksome. I'm trying to use the logs to
>> work out where things should be handled but aren't.
>>
>>
> Yeah, there's just a lot of code already in the client app that handles
> these errors, so it's quite possible that the errors you're trying to
> capture are being intercepted elsewhere in the code and either handled
> transparently or with the guacNotification() code.  That's why I ask about
> this.  Are you modifying things inside the guacamole/src/main/webapp/app/rest
> directory, or elsewhere?  It really depends on what you're trying to do,
> but there are several instances where 404s, for example, are part of the
> normal operation of the client and just get handled transparently within
> the client without bothering the user about it, so I'm wondering if the
> 404s you're seeing are already being handled and never making it to the
> code you're writing.
>
> -Nick
>



-- 
All the best,
Erin Versfeld

Re: Console.log messages not included post minification

Posted by Nick Couchman <vn...@apache.org>.
On Wed, Nov 1, 2017 at 9:01 AM, Erin Versfeld <er...@gmail.com>
wrote:

> Thanks, Ryan and Nick,
>
> I've played around with all the log settings in the browser console, and
> run my app on multiple browsers, so that at least can be rules out as an
> issue for now.
>
> Looking more closely at minify-maven, one of the tools its built on top of
> is Google's Closure Compiler, which "parses your JavaScript, analyzes it,
> removes dead code and rewrites and minimizes what's left", which could
> potentially explain this behaviour. Commenting out that whole process from
> the pom file then breaks things because app.js isn't build. I'm playing
> around with changing the index.html and seeing if just pointing it to the
> individual .js files works, but alternative suggestions are also welcome.
>
> I tried injecting the $log service, but had no luck. It's entirely
> possible that I wasn't doing it correctly, though, so I'm heading back to
> the docs to confirm that.
>

In the file where you want to use it, simply find the sections toward the
top of the file that have one or more $injector.get lines, and add the
following:

var $log = $injector.get('$log');

Then elsewhere in your code use $log.debug('Your debug message here.') to
get the output (or $log.info(), $log.warn(), $log.error()).

It's also possible that the lines of code where you're attempting to put
log statements aren't actually being reached, so make sure you're putting
those statements in places that you absolutely know are executing.



>
> I am modifying the client rather than using the API portions of the client
> code to write a custom app. The kinds of errors I expect to see are the
> stock standard HTTP errors, like 404s, 500s, etc. I'd just like to have a
> little pop up or display a relevant error message when these errors occur.
> The browser is able to tell which of these errors has occurred, so it looks
> like everything is working as expected, its just handling this on the
> client side which is proving irksome. I'm trying to use the logs to work
> out where things should be handled but aren't.
>
>
Yeah, there's just a lot of code already in the client app that handles
these errors, so it's quite possible that the errors you're trying to
capture are being intercepted elsewhere in the code and either handled
transparently or with the guacNotification() code.  That's why I ask about
this.  Are you modifying things inside the
guacamole/src/main/webapp/app/rest directory, or elsewhere?  It really
depends on what you're trying to do, but there are several instances where
404s, for example, are part of the normal operation of the client and just
get handled transparently within the client without bothering the user
about it, so I'm wondering if the 404s you're seeing are already being
handled and never making it to the code you're writing.

-Nick

Re: Console.log messages not included post minification

Posted by Erin Versfeld <er...@gmail.com>.
Thanks, Ryan and Nick,

I've played around with all the log settings in the browser console, and
run my app on multiple browsers, so that at least can be rules out as an
issue for now.

Looking more closely at minify-maven, one of the tools its built on top of
is Google's Closure Compiler, which "parses your JavaScript, analyzes it,
removes dead code and rewrites and minimizes what's left", which could
potentially explain this behaviour. Commenting out that whole process from
the pom file then breaks things because app.js isn't build. I'm playing
around with changing the index.html and seeing if just pointing it to the
individual .js files works, but alternative suggestions are also welcome.

I tried injecting the $log service, but had no luck. It's entirely possible
that I wasn't doing it correctly, though, so I'm heading back to the docs
to confirm that.

I am modifying the client rather than using the API portions of the client
code to write a custom app. The kinds of errors I expect to see are the
stock standard HTTP errors, like 404s, 500s, etc. I'd just like to have a
little pop up or display a relevant error message when these errors occur.
The browser is able to tell which of these errors has occurred, so it looks
like everything is working as expected, its just handling this on the
client side which is proving irksome. I'm trying to use the logs to work
out where things should be handled but aren't.

Thanks for all your advice!

All the best,
Erin



On Mon, Oct 30, 2017 at 11:15 PM, Nick Couchman <vn...@apache.org> wrote:

> On Mon, Oct 30, 2017 at 03:19 ErinVersfeld <er...@gmail.com> wrote:
>
>> I'm new to Guacamole, and am trying to adapt the base client for a project
>> I'm working on. However, I'm having trouble with getting my console.log
>> message to be included in the minified JavaScript. I'm assuming that it's
>> the minification process that's removing them, because the logs are in the
>> source code on my machine, but I can't work out where  the minification is
>> happening. Do you perhaps have any advice for me?
>>
>
> I've never had the minification process strip out log messages. However, I
> have noticed that Chrome seems to filter then by default.  There's an
> option when you're looking at the console to change what messages get
> displayed - make sure that you have it set to show all messages.
>
> Also, it's a little cleaner to inject the $log service into the angular
> code you're writing and use $log.debug() (or warn/info) and use that to log
> your messages.
>
>
>> I'm trying to use the logs to work out why my modified version of the
>> client
>> isn't displaying HTTP error messages, even though they're coming through
>> to
>> it. I've also tried using dummy variable to track a similar thing, but I
>> can't get that working either. I'm using tomcat 7 and Xtightvnc.
>>
>
> Are you modifying the client or are you just using the API (-common)
> portions of the client code to write a custom app?  Can you explain further
> where/how you're trying to throw these errors and what your expect to see?
> Also, if you're using Chrome, use the network tab of the dev console to see
> the requests and responses, including response codes and bodies.  This may
> help you see the error if it's being intercepted by some part of the client
> and not pushed all the way through.
>
> -Nick
>



-- 
All the best,
Erin Versfeld

Re: Console.log messages not included post minification

Posted by Nick Couchman <vn...@apache.org>.
On Mon, Oct 30, 2017 at 03:19 ErinVersfeld <er...@gmail.com> wrote:

> I'm new to Guacamole, and am trying to adapt the base client for a project
> I'm working on. However, I'm having trouble with getting my console.log
> message to be included in the minified JavaScript. I'm assuming that it's
> the minification process that's removing them, because the logs are in the
> source code on my machine, but I can't work out where  the minification is
> happening. Do you perhaps have any advice for me?
>

I've never had the minification process strip out log messages. However, I
have noticed that Chrome seems to filter then by default.  There's an
option when you're looking at the console to change what messages get
displayed - make sure that you have it set to show all messages.

Also, it's a little cleaner to inject the $log service into the angular
code you're writing and use $log.debug() (or warn/info) and use that to log
your messages.


> I'm trying to use the logs to work out why my modified version of the
> client
> isn't displaying HTTP error messages, even though they're coming through to
> it. I've also tried using dummy variable to track a similar thing, but I
> can't get that working either. I'm using tomcat 7 and Xtightvnc.
>

Are you modifying the client or are you just using the API (-common)
portions of the client code to write a custom app?  Can you explain further
where/how you're trying to throw these errors and what your expect to see?
Also, if you're using Chrome, use the network tab of the dev console to see
the requests and responses, including response codes and bodies.  This may
help you see the error if it's being intercepted by some part of the client
and not pushed all the way through.

-Nick