help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] Code update and class variables


From: Paolo Bonzini
Subject: Re: [Help-smalltalk] Code update and class variables
Date: Tue, 7 Sep 2010 10:23:26 +0200

On Tue, Sep 7, 2010 at 03:45, Holger Hans Peter Freyther
<address@hidden> wrote:
> Header File:
> http://git.osmocom.org/gitweb?p=libosmocore.git;a=blob;f=include/osmocore/logging.h;h=7f33155a8330d5bc59d0262140ed3e8fea34050a;hb=HEAD

Ok, so...

  73 struct log_target {
  74         struct llist_head entry;
  75
  76         int filter_map;
  77         void *filter_data[LOG_MAX_FILTERS+1];
  78
  79         struct log_category categories[LOG_MAX_CATEGORY+1];
  80         uint8_t loglevel;
  81         int use_color:1;
  82         int print_timestamp:1;
  83
  84         union {
  85                 struct {
  86                         FILE *out;
  87                         const char *fname;
  88                 } tgt_file;
  89
  90                 struct {
  91                         int priority;
  92                 } tgt_syslog;
  93
  94                 struct {
  95                         void *vty;
  96                 } tgt_vty;
  97         };
  98
  99         void (*output) (struct log_target *target, const char *string);
 100 };

I would not be too fussy about reproducing the exact characteristics of the API.

I guess subsys is what you called "area".

The basic hierarchy here is

LogEntry (simple struct: subsys/level/context replacing file+line/string)
LogTarget (methods create LogEntry and pass it to an abstract method)
    LogFilter (see below)
    LogFile (better: LogStream?)
    LogSyslog

LogFilters wrap another LogTarget and only pass through items in a
select category.  You can have class methods to create commonly used
filters, or you can make a subhierarchy like

    LogFilter (abstract)
        LogAreaFilter (enable one area or disable one area)
            LogEnableAreaFilter
            LogDisableAreaFilter
        LogLogicFilter
            LogAndFilter
            LogOrFilter
            LogNotFilter
        LogLevelFilter
        LogPluggableFilter

but that can come later.

LogTarget class methods can be used to set a default logging target
and, as you mentioned, you could have also a per-process LogTarget.

You can add a LogMultiplexer class to emulate
log_add_target/log_del_target.  It can be just an internal detail.

How does this look?

Paolo



reply via email to

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