Adding Logging to Plugin

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
Dominus
Posts: 10
Joined: 11 Aug 2020, 05:36

Adding Logging to Plugin

Post by Dominus »

I am in the process of trying to make a plugin for Mantis, but I want to have logging built in to it. However, I'm missing how exactly one would add an entry to the log with it denoted as a plugin.

Code: Select all

log_event(LOG_FILTERING,$this->name);
works perfectly. But change it to LOG_PLUGIN and it spits out

Code: Select all

SYSTEM NOTICE: 'Use of undefined constant LOG_PLUGIN - assumed 'LOG_PLUGIN''
. Any ideas?
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Adding Logging to Plugin

Post by cas »

This is described in the admin guide as of page 59, did you verify already?
Dominus
Posts: 10
Joined: 11 Aug 2020, 05:36

Re: Adding Logging to Plugin

Post by Dominus »

I have reviewed https://www.mantisbt.org/docs/master/en ... l-desktop/ . Is there another guide that tells me how to add logging to the code of a plug in? The logs are outputting correctly for core (using LOG_ALL).
Mantis 2.25.1
PHP 7.4.19
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Adding Logging to Plugin

Post by cas »

LOG_ALL should also take care of the plugin logging so something else is happening.
log_event(LOG_PLUGIN, 'problem with this'.$name); should work.
Which version are you using?
Dominus
Posts: 10
Joined: 11 Aug 2020, 05:36

Re: Adding Logging to Plugin

Post by Dominus »

Mantis 2.5.1, schema 209. Log_event works if i use LOG_FILTERING. If I use LOG_PLUGIN, it says undefined constant.
Mantis 2.25.1
PHP 7.4.19
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Adding Logging to Plugin

Post by cas »

check core/constants_inc.php if it is defined in there.
If not add it or even better upgrade your Mantis to latest & greatest version.
Dominus
Posts: 10
Joined: 11 Aug 2020, 05:36

Re: Adding Logging to Plugin

Post by Dominus »

That was it! I was confused due to being on 2.5.1 and the latest version being 2.24. It works as intended in the latest version.
Mantis 2.25.1
PHP 7.4.19
Post Reply