Complete.Org: Mailing Lists: Archives: freeciv-ai: August 2002:
[freeciv-ai] Re: rfc: logging
Home

[freeciv-ai] Re: rfc: logging

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "Per I. Mathisen" <per@xxxxxxxxxxx>
Cc: freeciv-ai@xxxxxxxxxxx
Subject: [freeciv-ai] Re: rfc: logging
From: Raimar Falke <rf13@xxxxxxxxxxxxxxxxx>
Date: Tue, 13 Aug 2002 11:29:22 +0200

On Mon, Aug 12, 2002 at 10:18:23PM +0000, Per I. Mathisen wrote:
> In the attached patch I have macros that wrap freelog for more uniform and
> informative log messages from the AI code. I want some feedback on it. It
> is not optimal, since you can't add more varargs to it (tried some other
> variants but none worked well). It should have option to specify your own
> loglevel but that's secondary.
> 
> Please suggest something better. We need something like this to get decent
> logging of the AI and find bugs.

> +#define LOG_BODYGUARD LOG_VERBOSE
> +#define LOG_UNIT LOG_VERBOSE
> +
> +#define UNIT_LOG(punit, msg)                                \

LOG_UNIT and UNIT_LOG are too easy to mix. Rename LOG_UNIT to
UNIT_LOG_LEVEL or similar.

> +  freelog(LOG_UNIT, "%s's %s[%d] (%d,%d)->(%d,%d) " ##msg##,\
> +          unit_owner(punit)->name, unit_type(punit)->name,  \
> +          punit->id, punit->x, punit->y,                    \
> +          punit->goto_dest_x, punit->goto_dest_y);
> +
> +#define BODYGUARD_LOG(punit, msg)                               \
> +{                                                               \
> + struct unit *pcharge = find_unit_by_id(punit->ai.charge);      \

This may yield "unused variable warnings" or worst may always be
executed.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  The Software is not designed or licensed for use in on-line control
  equipment in hazardous environments, such as operation of nuclear
  facilities, aircraft navigation or control, or direct life support
  machines. 
    -- Java Compiler Compiler Download and License Agreement


[Prev in Thread] Current Thread [Next in Thread]