Net::SIP::Debug(3pm)

πŸ’– Net::SIP::Debug πŸ’–

okay bestie, gather round, because this is the page for Net::SIP::Debug β€” the debugging glow-up for Net::SIP, straight out of the User Contributed Perl Documentation section of your friendly neighbourhood 3pm manual. it's giving "I put a little print statement in there and now I know everything" energy. πŸŽ€


✨ NAME ✨

Net::SIP::Debug β€” debugging of Net::SIP 🌸


πŸ¦‹ SYNOPSIS πŸ¦‹

use Net::SIP::Debug '1';
use Net::SIP::Debug qw( Net::SIP*=0 Registrar=1 );
Net::SIP::Debug->level(1);

perl -MNet::SIP::Debug=1 app.pl

πŸ’… DESCRIPTION πŸ’…

So here's the vibe: this module provides debugging support for Net::SIP. Debugging can be turned on and off globally, or per package, and optionally per subpackage too. mix and match, it's your world. ✨

It also supports different debugging levels β€” and the way that works is: the higher the level, the more debugging gets done. no cap. Here are the levels it uses:

  • 1 β€” Debug messages for users. 🫢
  • 2 β€” Includes short SIP packet dumps of incoming and outgoing data.
  • 5 β€” Includes detailed SIP packet dumps for incoming and outgoing data.
  • 10 β€” Includes information about call flow, e.g. why packets get dropped etc. πŸ‘€
  • 50 β€” Detailed debugging for programmers using Net::SIP.
  • 100 β€” Detailed debugging for core developers of Net::SIP. πŸ‘‘

πŸ‘‘ CLASS METHODS πŸ‘‘

🌈 import ( @ARGS )

Extracts everything from the arguments given to use which might be usable by level, and forwards the rest to Exporter. teamwork, love that.

If the argument is a reference to a subroutine, that sub will be used for showing the debug message instead of printing it to STDERR. In that case the usual prefixes β€” including the time β€” will not be added (which is genuinely useful for forwarding debug to syslog, iykyk).

🌈 level ( @ARGS )

Enables/disables debugging depending on @ARGS. And @ARGS might contain the following specifications:

  • NUMBER β€” NUMBER gets interpreted as the debugging level. It's used in debug etc. to print only debug messages which have a level lower or equal to NUMBER.
  • PACKAGE β€” Enables debugging for package PACKAGE. PACKAGE might be a fully qualified package (e.g. "Net::SIP::Registrar"), or the "Net" or "Net::SIP" might be omitted (so just "Registrar" works too). If a "*" is added, the debugging will also be enabled for subpackages β€” e.g. "Endpoint*" will enable debugging for Net::SIP::Endpoint and Net::SIP::Endpoint::Context too. star power fr. ⭐
  • PACKAGE=NUMBER β€” Similar to the previous item, but this one sets the debugging level to NUMBER for the specified packages, which means you can also use it to selectively disable debugging for some packages. yes, you can turn it OFF for specific ones. iconic.

If @ARGS is empty, it will return the debugging level for the package which called this method β€” that's the first package in the caller stack which is not Net::SIP::Debug itself. πŸ”

🌈 set_prefix ( PREFIX )

Sets the prefix used for debug messages to PREFIX. The default prefix is 'DEBUG:', but for instance for forking applications it might be useful to change this to "DEBUG($$):" or something similar. πŸ’…


πŸŽ€ SUBROUTINES πŸŽ€

πŸ’œ DEBUG|debug ( [ LEVEL ],( MESSAGE | FMT,@ARG ))

If debugging is enabled, it will print debugging info to STDERR. If multiple arguments are given to the function, they get fed into sprintf to create a single message. ✨

If the first argument looks like a number (see looks_like_number in Scalar::Util), it will be interpreted as the debug level for this message β€” e.g. if it's higher than the user-specified debug level, the message will not be printed.

The MESSAGE (or the result from "sprintf(FMT,@ARG)") will be prefixed by the caller package, the caller function, and the line from which DEBUG was called. In front of that prefix, the current time (as float time_t) and the string "DEBUG:" get added. πŸ•

If the message consists of multiple lines, each line will be prefixed by the prefix, and all but the first line will also have a TAB added between the prefix and the message data. cute formatting honestly.

The function is by default exported as DEBUG, and can be exported as debug too.

πŸ’œ DEBUG_DUMP ( [ LEVEL ], @DATA )

Will call debug with the output from Data::Dumper's Dumper if debugging is enabled. If @DATA has more than one item, it will be fed as a reference into Dumper; otherwise only the single item will be fed to Dumper. For the meaning of LEVEL, see debug. 🫢

This function is exported by default.

πŸ’œ stacktrace ( MESSAGE | FMT,@ARG )

Uses the arguments in debug, but instead of writing a debug message to STDERR, it will be used in Carp::longmess. Returns a string with the stacktrace. we love a good "how did I even get here" moment. 😭

πŸ’œ LEAK_TRACK ( REF )

This one is used internally for tracking leaks. It will rebless REF into a new class which behaves like the old one. Calls of LEAK_TRACK and DESTROY on this class will be tracked and shown. If Devel::Peek can be loaded, it will Dump information about the REF on each call to LEAK_TRACK. πŸ”

Exported by default.


🌸 exported Variables 🌸

πŸ“ $DEBUG

This variable is set to false if all kinds of debugging are disabled. It's exported by default. It should not be changed. It's intended to be used as a quick check to save expensive calls of debugging functions if no debugging will be used anyway, i.e.:

$DEBUG && DEBUG(...)
bestie pls do not touch $DEBUG. it is simply a lil vibe check for your code. hands off. πŸ™ˆ

and that's the whole page, periodt. πŸ’–βœ¨

Net::SIP::Debug(3pm) came to you via perl v5.40.1, dated 2025-12-07, part of the User Contributed Perl Documentation. slay, go forth and DEBUG responsibly. πŸ¦‹πŸ‘‘πŸ’…

πŸ“¦ where this page comes from