[ 
https://issues.apache.org/jira/browse/TS-2106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13733548#comment-13733548
 ] 

Igor Galić commented on TS-2106:
--------------------------------

right now I'm toying with the idea to rip out the gzip plugin's debug macros: 
{code}

#define debug(fmt, args...) do {                                    \
  TSDebug(PLUGIN_NAME, "DEBUG: [%s:%d] [%s] " fmt, __FILE__, __LINE__, 
__FUNCTION__ , ##args ); \
  } while (0)

#define info(fmt, args...) do {                                    \
  TSDebug(PLUGIN_NAME, "INFO: " fmt, ##args ); \
  } while (0)

#define warning(fmt, args...) do {                                    \
  TSDebug(PLUGIN_NAME, "WARNING: " fmt, ##args ); \
} while (0)
          
#define error(fmt, args...) do {                                    \
  TSError("[%s], [%s:%d] [%s] ERROR: " fmt, PLUGIN_NAME, __FILE__, __LINE__, 
__FUNCTION__ , ##args ); \
  TSDebug(PLUGIN_NAME, "[%s:%d] [%s] ERROR: " fmt, __FILE__, __LINE__, 
__FUNCTION__ , ##args ); \
} while (0)

#define fatal(fmt, args...) do {    \
  error(fmt, ##args );             \
  exit(-1);                         \
} while (0)
{code}

These should work out really fine, but with a caveat: you need to define 
PLUGIN_NAME before including {{<ts/ts.h>}}
                
> Normalize TSError messages in plugins (and examples)
> ----------------------------------------------------
>
>                 Key: TS-2106
>                 URL: https://issues.apache.org/jira/browse/TS-2106
>             Project: Traffic Server
>          Issue Type: Bug
>          Components: Plugins
>            Reporter: Igor Galić
>
> right now many of plugins send error messages without prefixing the plugin 
> they come from, this bad practice is also continued in our examples.
> many error messages also close with {{\n}}, although this is not necessary.
> We should fix this by "normalizing" the way we send those error messages.
> Our proposal is either:
> {code}
> TSError("%s: cannot parse file %s", PLUGIN_NAME, filename);
> {code}
> or:
> {code}
> TSError("[%s] cannot parse file %s", PLUGIN_NAME, filename);
> {code}
> I have no strong leanings towards either. BUT: We should have one consistent 
> format between examples and plugins and newly imported code. The word "error" 
> should not be repeated, as it is already in the "severity" ({{TSError()}}. 
> There should be *no* {{\n}} at the end of the message.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to