How to output Zend log information to chrome debugger console? - zend-framework

With Zend Framework 1.12 you can use Zend_Log_Writer_Firebug to write log information to the firebug console. Is there a way to pass the output to the chrome debugger console?
$logger = new Zend_Log();
$writer = 'production' == $this->getEnvironment() ? new Zend_Log_Writer_Stream(APPLICATION_PATH .'/../data/logs/app.log') : new Zend_Log_Writer_Firebug();
$logger->addWriter($writer);
if ('production' == $this->getEnvironment()) {
$filter = new Zend_Log_Filter_Priority(Zend_Log::DEBUG);
$logger->addFilter($filter);
}
$this->_logger = $logger;
Zend_Registry::set('log', $logger);
}

I am using Chrome Logger. It's a little bit more complicated than with Firebug but no big deal:
install the extension for your Chrome browser
include ChromePHP in your composer.json (that's the way I do it - if you have a different application include path, put it there)
now you can use Zend\Log\Writer\ChromePHP to send debug-information to your Chrome-console.

Related

Moodle can't redirect to page after installation

I have just installed Moodle on my web-server. Everything was OK until I came to page where I saw this text: "This page should automatically redirect. If nothing is happening please use the continue link below. Continue."
When I click on Continue, the same page shows again. I deleted all data from moodledata folder (saw it on this site), but I have the same problem again and again. What can be a problem here and how to solve it?
Thank you in advance.
The first step to do is to enable debugging. I assume you can not access site administration anymore so you have to enable debugging in the config.php file. The file is located in /path/to/moodle/config.php (that means in the root folder of your Moodle installation).
The first lines should look like that in config.php. That means you have to add the 4 lines which are under $CFG = new stdClass();
<?php // Moodle configuration file
unset($CFG);
global $CFG;
$CFG = new stdClass();
#error_reporting(E_ALL | E_STRICT); // NOT FOR PRODUCTION SERVERS!
#ini_set('display_errors', '1'); // NOT FOR PRODUCTION SERVERS!
$CFG->debug = (E_ALL | E_STRICT); // === DEBUG_DEVELOPER - NOT FOR PRODUCTION SERVERS!
$CFG->debugdisplay = 1; // NOT FOR PRODUCTION SERVERS!
After that open Moodle in your browser. A debug message will be displayed. Post the error message in order to get additional help so solve the problem.

Calling Openoffice from Perl throws NoSuchElementexception

I try to convert odt-Files to doc-Files using OpenOffice. Installed Version is 3.1.1 and can't be changed at the moment. Perl Version is 5.18.
The Perl-module OpenOffice::UNO is used for this conversion. Unfortunately in newer Versions of OpenOffice/LibreOffice do not support Perl anymore.
The Script calls OpenOffice headless using xvfb.
Here is the code used:
`# Launch OpenOffice.org as a server
$ ooffice \
"-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager"
use OpenOffice::UNO;
# connect to the OpenOffice.org server
$uno = OpenOffice::UNO->new;
$cxt = $uno->createInitialComponentContext('file:///.../path/perluno');
$sm = $cxt->getServiceManager;
$resolver = $sm->createInstanceWithContext
("com.sun.star.bridge.UnoUrlResolver", $cxt);
$rsm = $resolver->resolve
("uno:socket,host=localhost,port=8100;urp;StarOffice.ServiceManager");
# get an instance of the Desktop service
$rc = $rsm->getPropertyValue("DefaultContext");
$desktop = $rsm->createInstanceWithContext("com.sun.star.frame.Desktop", $rc);
.....`
On the last included line to create $desktop i get following Error message:
terminate called after throwing an instance of 'com::sun::star::container::NoSuchElementException'
Is there any way to fix this problem? Tried to understand the Code of the UNO-interface, especially UNO.xs but there has not been any information about the call "createInstanceWithContext".
Looking through the OpenOffice-documentation does not provide any information about this either.
It would also help just to get the complete java error message, to make sure what element is missing.
The file "perluno" has the content:
[Bootstrap]
UNO_TYPES=/usr/lib64/openoffice.org//program/types.rdb
UNO_SERVICES=/usr/lib64/openoffice.org//program/services.rdb

Do I need to enable javascript for PhantomJS when using Selenium Webdriver?

I have a testsuite in NUnit running on both IE and Chrome webdrivers. But when I wanted to try headerless PhantomJS (Ghostdriver) I can't get it to excute the actions I want to perform.
Having issues with easy stuff like
[TestFixture]
class PhantomJSTest{
protected IWebDriver driver;
[SetUp]
public void Setup() {
driver = new PhantomJSDriver(#"..\..\..\..");
}
[Test]
public void PhantomTest() {
driver.Navigate().GoToUrl(adress);
driver.FindElement(selector).Click();
}
[TearDown]
public void Teardown() {
driver.Close();
driver.Quit();
}
}
When the click is performed something should be set in my db, so when going back to that page manually I should be able to see it. The NUnit test itself is set to succeeded, but the action never happens. This is especially apparent when trying to do something based on the earlier action. Any help would be appreciated! =)
I would recommend you following activities:
1) try to relaunch your selenium hub with node(-s) based on phantomJs.
2) try to use instead of
driver.Navigate().GoToUrl(adress);
this one:
driver.get(URL);
driver.findElement(selector).click();
3) also see phantomJs documentation to get all phantomJs capabilities:
GhostDriver extra Capabilities
phantomjs.page.settings.SETTING = VALUE - Configure page.settings on
PhantomJS internal page objects (windows in WebDriver context) . Reference
phantomjs.page.customHeaders.HEADER = VALUE - Add extra HTTP Headers
when loading a URL . Reference
PhantomJSDriver (Java-binding) Capabilities
phantomjs.binary.path - Specify path to PhantomJS executable to use
phantomjs.ghostdriver.path - Specify path to GhostDriver main/src.js
script to use; allows to use a different version of GhostDriver then
the one embed in PhantomJS
phantomjs.cli.args - Specify command line arguments to pass to the
PhantomJS executable
phantomjs.ghostdriver.cli.args - Specify command line argument to
pass to GhostDriver (works only in tandem with
phantomjs.ghostdriver.path)
More details one can get at GhostDriver page
Also look through phantomJs command line options . This info might be helpful for you as well.
Hope this helps you.

WURFL with Zend Framework ignoring cache directory configuration

I'm following the tutorial on setting up WURFL with Zend Framework to enable easy mobile browser detection.
http://framework.zend.com/manual/en/zend.http.user-agent.html#zend.http.user-agent.quick-start
I have got it setup to the point where it can detect a desktop browser and give me all the details and features of that browser, but when I try to access the website using an iPhone (mobile safari) it throws an error when trying to write to the cache directory.
Here's what I'm seeing in my error logs:
2011-06-08T22:32:34-07:00 ERR (3): The file cache directory does not exist and could not be created. Please make sure the cache directory is writeable: /var/tmp
However in my configuration at /application/configs/wurfl-config.php I have set the cache directory to the following:
<?php
$resourcesDir = dirname(__FILE__) . '/../../data/wurfl/';
$wurfl['main-file'] = $resourcesDir . 'wurfl-2.0.27.zip';
$wurfl['patches'] = array($resourcesDir . 'web_browsers_patch.xml');
$persistence['provider'] = 'file';
$persistence['dir'] = $resourcesDir . '/cache/';
$cache['provider'] = null;
$configuration['wurfl'] = $wurfl;
$configuration['persistence'] = $persistence;
$configuration['cache'] = $cache;
I've also ensured it is writable by the server, but wurfl seems to think my cache directory is still /var/tmp
How can I get wurfl to observe my cache directory setting?
Notes: The tutorial uses wurfl-1.1 as the example, I have only been able to find wurfl-1.3 on sourceforge. This may be an issue.
Notes: I have these lines in my application.ini file:
; WURFL
resources.useragent.wurflapi.wurfl_api_version = "1.1"
resources.useragent.wurflapi.wurfl_lib_dir = APPLICATION_PATH "/../library/wurfl-php-1.3.0/WURFL/"
resources.useragent.wurflapi.wurfl_config_file = APPLICATION_PATH "/configs/wurfl-config.php"
Not sure if this is the correct way to fix it, but for me the issue was solved by adding an extra .dir after the persistence.dir key (using WURFL 1.3.0):
In application.ini: (I don't use the php config file as I prefer not to mix in php code if I can use .ini directives)
resources.useragent.wurflapi.wurfl_config_array.persistence.dir.dir = APPLICATION_PATH "/../data/wurfl/cache/"
So my complete config for WURFL looks like this in Zend's application.ini:
; Mobile device detection
resources.useragent.storage.adapter = "Session"
resources.useragent.wurflapi.wurfl_api_version = "1.1"
resources.useragent.wurflapi.wurfl_lib_dir = APPLICATION_PATH "/../library/WURFL/"
resources.useragent.wurflapi.wurfl_config_array.wurfl.main-file = APPLICATION_PATH "/../data/wurfl/wurfl.xml"
resources.useragent.wurflapi.wurfl_config_array.wurfl.patches[] = APPLICATION_PATH "/../data/wurfl/web_browsers_patch.xml"
resources.useragent.wurflapi.wurfl_config_array.persistence.provider = "file"
resources.useragent.wurflapi.wurfl_config_array.persistence.dir.dir = APPLICATION_PATH "/../data/wurfl/cache/"
perhaps a bug in the framework regarding how it reads the config array it's being passed?
I just resolved the problem ;)
remove the [] from the code line below:
resources.useragent.wurflapi.wurfl_config_array.wurfl.patches[] = APPLICATION_PATH "/../data/wurfl/web_browsers_patch.xml"
transform it to:
resources.useragent.wurflapi.wurfl_config_array.wurfl.patches = APPLICATION_PATH "/../data/wurfl/web_browsers_patch.xml"
It seems the format of the parameters has changed in version 1.3 - the WURFL docs here have the details and an example file.
So for the original question, the $persistence['dir'] line needs to be changed to:
$persistence['params'] = array(
'dir' => $resourcesDir . '/cache/'
);
I solved the problem using Wurfl 1.3.1 and reading this:
http://wurfl.sourceforge.net/nphp/
With regards to Jens Wegar's answer above, there is a bug-fix request in to fix this as it's not clear.
http://framework.zend.com/issues/browse/ZF-12284
Did you configure the UserAgent resource to use the settings you are showing here?
You have to add resource.useragent.wurfl_* entries into your application.ini file.
Here is a sample:
resources.useragent.wurflapi.wurfl_api_version = "1.1"
resources.useragent.wurflapi.wurfl_lib_dir = APPLICATION_PATH "/../library/WURFL/"
resources.useragent.wurflapi.wurfl_config_file = APPLICATION_PATH "/configs/wurfl-config.php"

console.log browser in android emulator

How to see console.log messages of a website using android emulator?
From Rich Chetwynd's short article "Javascript debugging on Android browser".
You can log javascript errors and console messages from your Android device or emulator. To do this you first need to install the Android SDK and USB drivers and enable USB debugging on the actual device.
To check if the device is connected correctly you can run the following cmd from your Android SDK tools directory and you should see a device in the list
c:\android sdk..\platform-tools\adb devices
You can then use the Android Debug Bridge to filter debug messages so that you only see browser related messages by running the following cmd.
c:\android sdk..\platform-tools\adb logcat browser:V *:S
By default the log is written to stdout so you will see any Javascript errors or console.log messages etc written to the cmd window.
Further details: Logcat CLI tool docs.
If you have started the emulator from Eclipse with the ADT plugin, you will see all JavaScript console logs directly under the LogCat view :
Window -> Show View -> Android -> LogCat
If you are using Android Studio; you can open your Logcat (Alt+6) and filter for: :CONSOLE
Filtering for only :CONSOLE (rather than INFO:CONSOLE) will display all types of console messages (including ERROR, WARN, etc).
You could add some JavaScript temporarily like...
var console = {
log: function(msg) { alert(msg); }
};
Ugly as hell, but it works.
I hijacked the console.log using this code:
function logManager() {
var self = this;
self.init = function () {
console.log('logmanager initialized');
var old = console.log;
self.logger = document.getElementById('log');
console.log = function (message, options) {
if (typeof message == 'object') {
self.logger.innerHTML = (JSON && JSON.stringify ? JSON.stringify(message) : message) + '<br />' + self.logger.innerHTML;
} else {
self.logger.innerHTML = message + '<br />' + self.logger.innerHTML;
}
}
}
self.toggleLogVisibility = function () {
return $(self.logger).toggle();
};
}
And consume it like so in your html with your own styling (absolute top right is what I used)
<div id="log" class="log">
Application loaded...
</div>
And in your jscript (run this on page loaded as the log element has to exist)
document.lmgr = new logManager();
document.lmgr.init();
Open this url on your chrome
chrome://inspect
Command - get log from the emulator
adb -e logcat
adb.exe can be found at $your_installation_path$\android sdk\platform-tools
more detailed
https://learn.microsoft.com/ru-ru/xamarin/android/deploy-test/debugging/android-debug-log?tabs=windows
If you cannot run adb logcat browser:V *:S because of zsh, you need to run noglob adb logcat browser:V *:S. Rationale: https://github.com/ohmyzsh/ohmyzsh/issues/2901