2.2. M2_Util

M2_Util::getLanguages()

Returns an array of site languages in shorthand form: "en", "da" etc.

M2_Util::getProfiling([$format], [$ipLimit])

Returns profiling information for the page.

$format can only be "html", and $ipLimit is an optional array that will exclude access to the profiling information from any IP address not in the array.

M2_Util::getQuickForm($id, [$options])

Returns an instance of PEARs HTML_QuickForm that has a few extra methods for interacting with Moski2.net like sending the form contents in an email and storing it in a container.

...TBD...

M2_Util::log($message, $identifier, [$severity])

Use this method to log to the Moski2.net system log. This way you will be able to see the events of your own application alongside with those of Moski2.net in a unified interface.

Log entries can be viewed in the administration and you can configure the logger to email you all log entries above a certain severity level (this is set up in the developer settings of the System Log.)

Table 30. Parameters for the log method

ParameterDescriptionDefault value
$message

The text string you wish to log.

''
$identifier

An identifier that allows you to group all logged events of this type. You can provide any string here, but make sure it is unique for this part of your application.

''
$severity

The severity of your event. Can be one of these strings:

  • DEBUG

  • INFO

  • NOTICE

  • WARNING

  • ERR

  • CRIT

  • ALERT

  • EMERG

'INFO'

Here's a simple example of logging an event:

<?php

M2_Util::log('Could not connect to remote service', 'MyConnector', 'ERR');

?>

Note

You can also set up Moski2.net to log PHP errors directly to the system log.