Raised This Month: $2 Target: $400
 0% 

logdebug.inc - Simple debug logging


Post New Thread Reply   
 
Thread Tools Display Modes
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 02-27-2015 , 14:09   Re: logdebug.inc - Simple debug logging
Reply With Quote #11

Quote:
Originally Posted by Powerlord View Post
Make the variables in this static on the off chance that a plugin is already using variables with these names.
Wouldn't work since both InitDebugLog and LogDebug need access.

Quote:
Originally Posted by Powerlord View Post
Check if char works for single characters instead of using an int. (int flagChar = '0'; looks weird to say the least).
bool FindFlagChar(AdminFlag flag, int &c)

Would need to use view_as<int> anyway. I agree that it's weird but it is what it is.

Quote:
Originally Posted by Powerlord View Post
adminFlag should be optional. After all, if you don't include DEBUG_ADMIN_CONSOLE or DEBUG_ADMIN_CHAT, it isn't used. Perhaps use ADMFLAG_GENERIC as the default value for adminFlag?
Agreed. Fixing.

Quote:
Originally Posted by Powerlord View Post
Adjust InitDebugLog to process multiple admin flags correctly or convert it to use AdminFlag types in its signature instead. Right now, the BitToFlag line looks like it's going to barf if I pass in ADMFLAG_KICK|ADMFLAG_BAN for example. This is perfectly acceptable to CheckCommandAccess and will only match if an admin has both flags.
Done.
__________________
Dr. McKay is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 02-27-2015 , 14:33   Re: logdebug.inc - Simple debug logging
Reply With Quote #12

Quote:
Originally Posted by Dr. McKay View Post
Wouldn't work since both InitDebugLog and LogDebug need access.
static on a global variable should restrict it to just the same file... which as far as I know includes stocks. I admit I haven't tried it on stocks, though, only regular functions.
__________________
Am I back? Well, we'll see.
Powerlord is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 02-27-2015 , 16:15   Re: logdebug.inc - Simple debug logging
Reply With Quote #13

Quote:
Originally Posted by ddhoward View Post
PHP Code:
// define NO_DEBUG before including this file to completely disable all debugging
#if defined NO_DEBUG
 
stock void InitDebugLog(const char[] convarName, const char[] debugTagint adminFlag) { }
 
stock bool LogDebug(const char[] formatany ...) { return false; }
 
#endinput
#endif 
That is already a feature.
No... that still compiles it into your plugin, just making it return false all the time and do nothing. NOP NOP NOP

Quote:
Originally Posted by Dr. McKay View Post
Good catch. Fixed. Also added an override with the same name as the cvar.



I don't think that would be possible with LogDebug's variable number of parameters.
Code:
#if !defined DEBUG
    stock DebugMsg(any:...){}
    //#define DebugMsg(%1)
    #endinput
#endif
I do it like this, but that still compiles the function with a function call everywhere.

You can just do

#define DebugMsg 0

or something like that, and then it won't compile in your final binary, but you'll see compiler warnings.
__________________

Last edited by Chdata; 02-27-2015 at 16:19.
Chdata is offline
splewis
Veteran Member
Join Date: Feb 2014
Location: United States
Old 02-27-2015 , 18:12   Re: logdebug.inc - Simple debug logging
Reply With Quote #14

Thanks for making this. I've never found a good way to have solid debug logging, but I really like this.
__________________
splewis is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 03-01-2015 , 18:06   Re: logdebug.inc - Simple debug logging
Reply With Quote #15

Also, way to return .sp/.inc file name / line / function name like in errorlogs?
__________________

Last edited by Chdata; 03-01-2015 at 18:07.
Chdata is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 03-01-2015 , 20:35   Re: logdebug.inc - Simple debug logging
Reply With Quote #16

Quote:
Originally Posted by Chdata View Post
Also, way to return .sp/.inc file name / line / function name like in errorlogs?
I'm fairly certain that you'd have to include that information yourself through the text passed to LogDebug().
__________________
ddhoward is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 03-02-2015 , 08:12   Re: logdebug.inc - Simple debug logging
Reply With Quote #17

Chdata - that would be an awesome feature
__________________
View my Plugins | Donate
TnTSCS is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 03-06-2015 , 07:32   Re: logdebug.inc - Simple debug logging
Reply With Quote #18

Irony
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 03-07-2015 , 04:32   Re: logdebug.inc - Simple debug logging
Reply With Quote #19

There was stuff in PAWN like __LINE__ and __FILE__ but they removed it.
__________________

Last edited by Chdata; 03-07-2015 at 04:56.
Chdata is offline
Alienmario
Senior Member
Join Date: Aug 2013
Old 04-13-2020 , 18:41   Re: logdebug.inc - Simple debug logging
Reply With Quote #20

I've improved upon the original include.

- Added cvar [basename]_parts which controls additional information that will be printed. Time, line, and tick count can be printed. Unfurtunately, I don't know a way to obtain which include called the log function. Time format can be passed in InitDebugLog.
- Set the default location of the location cvar to server console
Attached Files
File Type: inc logdebug.inc (6.6 KB, 12 views)
Alienmario is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:51.


Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Theme made by Freecode