On Wednesday, June 29, 2011 22:51:36 Jie Zhang wrote: > On Wed, Jun 29, 2011 at 6:17 PM, Mike Frysinger wrote: > > this translating of level into a string is already handled in > > src/cmd/cmd_debug.c:log_level_to_string(). so why dont we rip those to > > helper funcs out into src/global/log-error.c, make them into proper > > urj_* funcs, and then we can have urj_error_describe() use that. that > > way we always get a proper prefixed message (since the helper returns > > "unknown" in the default case).
i just generalized the string<->urj_log_level_t helpers in trunk
> The problem is what we want here as a parameter is something to tell
> what we describe is a warning or an error. urj_log_level_t is not
> suitable here. I was lazy and tried to avoid introducing a new type
> something like:
>
> typedef enum
> {
> ERROR,
> WARNING,
> }
> urj_error_or_warning_t;
>
> or define urj_error_describe as
>
> const char *
> urj_error_describe (urj_log_level_t level, bool is_error)
> {}
>
> But I'm afraid this is not intuitive when using.
>
> or define two interfaces:
>
> urj_error_describe () and urj_warning_describe ()
>
> both will call an internal urj_error_warning_describe (urj_log_level_t
> level, bool is_error)
>
> Which way do you like more?
i wonder why we have this at all. we already have urj_log_level_t declaring
whether something is an error, a warning, or something else. why are we
manually adding "Error:" and "Warning:" prefixes to the logged strings ? why
cant urj_log() prefix things appropriately based on the level ?
> >> 1. I cannot find a suitable errnum for some error messages in ICE-100B
> >> cable. I thought adding a new errnum like URJ_ERROR_ICE_100B. But does
> >> that means we need a number for each cable driver?
> >
> > we can add a general URJ_ERROR_CABLE if there's something missing. what
> > exactly is the case you're handling that the current URJ_ERROR_* dont
> > cover ?
>
> For example error when parsing HEX firmware file. Now I use a new one
> URJ_ERROR_FIRMWARE, which I think is better than the cable one since
> other cables can also use this.
i think adding a new general level like URJ_ERROR_INVALID_XXX where XXX could
be INPUT or FILE or DATA or something. then it can be used with any command
that takes a file for input.
-mike
signature.asc
Description: This is a digitally signed message part.
------------------------------------------------------------------------------ All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________ UrJTAG-development mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/urjtag-development
