Home modules.gotpike.org
Username: Password: [Create Account]
[Forgot Password?]

Modules

ADT
Database
GTK2
GUI
IP
PiJAX
Public
Sql
Stdio
Subversion
System
Tools
Xosd
lua
v4l2
wx

Recent Changes

Public.Parser.XML2 1.50
Public.ZeroMQ 1.1
Public.Template.Mustache 1.0
Public.Protocols.XMPP 1.4
Sql.Provider.jdbc 1.0

Popular Downloads

Public.Parser.JSON2 1.0
Public.Parser.JSON 0.2
GTK2 2.23
Public.Web.FCGI 1.8
Public.Parser.XML2 1.48


Pike Module Reference:

module version 0.01, prepared

  MODULE Public
Modules
Logging

  MODULE Public.Logging
Modules
PPP

  MODULE Public.Logging.PPP
Classes
Debug
DebugManager

Methods
get_default_manager()

Method get_default_manager

object(.DebugManager) Public.Logging.PPP.get_default_manager()

Returns

A systemwide DebugManager which will be used if you just inherit Public.Logging.PPP.Debug, so you can just use debug(...) (documentation: see DebugManager()->debug() without having to explicitely create a DebugManager for simple scripts and applications that don't (can) share 'their' VM with other scripts/applications anyway.

Example
class X {
 	inherit Public.Logging.PPP.Debug;
 	void test() {
 		debug("info", 0, "i have been called.\n");
 		// this is sufficient information because the backtrace
 		// will (unless configured otherwise) show from what file,
		// function and line the debug message comes from.
 	}
 }
  CLASS Public.Logging.PPP.DebugManager
Methods
debug()
do_throw()
get_backtrace()
get_debug()
get_default_backtrace()
get_default_debug()
get_default_stderr()
get_stderr()
set_backtrace()
set_debug()
set_default_backtrace()
set_default_debug()
set_default_stderr()
set_stderr()
unset_backtrace()
unset_debug()
unset_default_backtrace()
unset_default_debug()
unset_default_stderr()
unset_stderr()
Description

Debug/Log class. Per category levels can be set when to display/log a debug output or not. Fully configurable at runtime so that there is no need to restart the application/service in order to hunt down issues.

How the levels / categories work Every message has to be assigned a category, and a level. If the level of the message is lower or equal than the debug level configured for the category, the message will be printed/logged, otherwise discarded.

Example
DebugManager d = DebugManager();
d->debug("my category", 5, "this message will be discarded, "
+ "because default debug level is 0.\n");
d->debug("another category", 0, "this will be printed for "
+ "obvious reasons!\n");
d->set_debug("warn", 5); // print messags from the warn
			    // category up to level 5.
d->debug("warn", 2, "this will be printed, too.\n");
Note

Do not inherit this class in order to get easy access to debug() and do_throw(). See "See also"!

See also

Debug for a class that can be inherited and then provides easy access to debug() and do_throw() while the DebugManager can still be exchanged.


Method set_default_debug

void Public.Logging.PPP.DebugManager()->set_default_debug(int lvl)

Description

Sets the default debug level which is used for categories for which no specific level is set.

See also

set_debug(), get_default_debug()


Method get_default_debug

int Public.Logging.PPP.DebugManager()->get_default_debug()

Returns

The current default debug level.

See also

set_default_debug(), get_debug()


Method set_default_stderr

void Public.Logging.PPP.DebugManager()->set_default_stderr(object o)

Description

Sets the default "stderr object" to which the output is written to. Because the only expectation towards "stderr objects" is that they provide a ->write(string fmt, mixed ... args) (which is expected to render the message like sprintf() would) this can be anything from a Stdio.File over a file appender to a syslog wrapper.

If a message belongs to multiple categories, the message will be only printed once for every distinctive "stderr object".

Example
DebugManager dm = DebugManager();
dm->debug(([ "dogs" : 0, "cats" : 0]), "this will be printed only "
          + "once\n");
dm->set_stderr("cats", Stdio.stdout);
dm->debug(([ "dogs" : 0, "cats" : 0]), "this will be printed twice, "
          + "once on stderr, once on stdout.\n");
See also

set_stderr()


Method set_default_backtrace

void Public.Logging.PPP.DebugManager()->set_default_backtrace(int i)

Description

Sets the default backtrace level. Messages that will be printed will include a "backtrace" consisting of the file, line number, function (and the arguments to that function) from which the message originates if their level is lower or equal to the backtrace level they are subjected to (default or category specific backtrace level).

See also

set_backtrace(), get_default_backtrace(), unset_default_backtrace()


Method unset_default_backtrace

int Public.Logging.PPP.DebugManager()->unset_default_backtrace()

Description

Unsets the default backtrace level.

Returns

The current default backtrace level

See also

unset_backtrace(), set_default_backtrace(), get_default_backtrace()


Method unset_default_debug

int Public.Logging.PPP.DebugManager()->unset_default_debug()

Description

Unsets the default debug level.

Returns

The current default debug level.

See also

unset_debug(), set_default_debug(), get_default_debug()


Method get_default_backtrace

int Public.Logging.PPP.DebugManager()->get_default_backtrace()

Returns

The current default backtrace level.

See also

set_default_backtrace(), unset_default_backtrace(), get_backtrace()


Method unset_default_stderr

object Public.Logging.PPP.DebugManager()->unset_default_stderr()

Description

Unsets the default stderr object.

Returns

The default stderr object currently set.

Note

This will not return Stdio.stderr if none is set (although that is where in that case messages are printed to).

See also

unset_stderr(), set_default_stderr(), get_default_stderr()


Method get_default_stderr

object Public.Logging.PPP.DebugManager()->get_default_stderr()

Returns

The default stderr object currently set.

Note

This will not return Stdio.stderr if none is set (although that is where in that case messages are printed to).

See also

get_stderr(), set_default_stderr(), unset_default_stderr()


Method set_debug

void Public.Logging.PPP.DebugManager()->set_debug(string category, int lvl)

Description

Sets the debug level for a specific category.

See also

set_default_debug(), get_debug(), unset_debug() and especially DebugManager for an explanation of how the levels work.


Method unset_debug

int Public.Logging.PPP.DebugManager()->unset_debug(string category)

Description

Unsets the debug level for a specific category.

Returns

The level for the given category currently set.

See also

set_debug(), get_debug(), unset_default_debug()


Method get_debug

int Public.Logging.PPP.DebugManager()->get_debug(string category)

Returns

The level for the given category currently set.

See also

set_debug(), unset_debug(), get_default_debug()


Method set_stderr

void Public.Logging.PPP.DebugManager()->set_stderr(string category, object o)

Description

Sets the "stderr object" for the given category.

See also

get_stderr(), unset_stderr() and especially set_default_stderr() for an explanation which kind of objects can be used as a "stderr object".


Method unset_stderr

object Public.Logging.PPP.DebugManager()->unset_stderr(string category)

Description

Unsets the "stderr object" for the given category.

Returns

The "stderr object" for the given category currently set.

See also

set_stderr(), get_stderr(), unset_default_stderr()


Method get_stderr

object Public.Logging.PPP.DebugManager()->get_stderr(string category)

Returns

The "stderr object" for the given category currently set.

See also

set_stderr(), unset_stderr(), get_default_stderr()


Method debug

void Public.Logging.PPP.DebugManager()->debug(string cat, int level, string fmt, mixed ... args)
void Public.Logging.PPP.DebugManager()->debug(mapping(string : int) cats, string fmt, mixed ... args)

Description

Debug-/log-messages are passed to this function, which then decides whether they should be printed or not according to the categories and levels given, and the configuration of the DebugManager.

Parameter cat
Parameter cats
Parameter level

cat is the category a message belongs to, and level is the level of the message (higher leveled messages are less important, see also DebugManager for a description of how levels work).

cats is just a mapping of cat : level pairs, so you can supply that if you want your message to belong to multiple categories.

Parameter fmt

Format string (think sprintf()).

Parameter args

Additional parameters to be inserted into the message as directed by the format string.

Example
DebugManager dm = DebugManager();
dm->debug("warn", 2, "Some not too important warning in object %O\n", this);
dm->debug("info", 0, "Got called\n");
dm->debug(([ "mail" : 1, "info" : 3 ]), "A mail from %s arrived.\n",
          mail->get_from()); // belongs to different categories with
                             // different levels.
See also

set_default_debug(), set_debug(), set_default_backtrace(), set_backtrace(), do_throw()


Method set_backtrace

void Public.Logging.PPP.DebugManager()->set_backtrace(string category, int trace)

Description

Sets the backtrace level for a specific category.

See also

set_default_backtrace() for an explanation of what backtraces are in this context, get_backtrace() and unset_backtrace()


Method unset_backtrace

int Public.Logging.PPP.DebugManager()->unset_backtrace(string category)

Description

Unsets the backtrace level for a specific category.

Returns

The backtrace level for the given category currently set.

See also

set_backtrace(), get_backtrace(), unset_default_backtrace()


Method get_backtrace

int Public.Logging.PPP.DebugManager()->get_backtrace(string c)

Returns

The backtrace level for the given category currently set.

See also

set_backtrace(), unset_backtrace(), get_default_backtrace()


Method do_throw

void Public.Logging.PPP.DebugManager()->do_throw(string fmt, mixed ... args)

Description

This function is a wrapper to throw() that will render the exception message using sprintf(fmt, @args) and include a backtrace if (and only if) either the default backtrace level or the backtrace level for the category "exception" is 0 or higher.

So you can disable backtraces by

Example
debugmanager->set_backtrace("exception", -1);
  CLASS Public.Logging.PPP.Debug
Methods
create()
debug()
do_throw()
Description

This class can be inherited so that debug and do_throw (from DebugManager) can be directly used while the DebugManager can still be exchanged.


Method do_throw

void Public.Logging.PPP.Debug()->do_throw(string fmt, mixed ... args)

Description

See DebugManager()->do_throw()


Method debug

void Public.Logging.PPP.Debug()->debug(string category, int level, string fmt, mixed ... args)
void Public.Logging.PPP.Debug()->debug(mapping(string : int) cats, string fmt, mixed ... args)

Description

See DebugManager()->debug()


Method create

void Public.Logging.PPP.Debug()->create(object(.DebugManager)|void s)

Parameter s

The DebugManager this object reports to.

If Public.Logging.PPP is present (it usually is, when you installed it from/by monger, and might be not if this class is shipped to you for example by the ppp and you don't have installed Public.Logging.PPP via monger, a VM-global default DebugManager will be used, obtainable by calling Public.Logging.PPP.get_default_manager(). In that case, create() may not be called at all (if you inherit this class and overload create()), or with an empty argument list, which will both lead to the default DebugManager being used.

gotpike.org | Copyright © 2004 - 2019 | Pike is a trademark of Department of Computer and Information Science, Linköping University