You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by Steve Huston <sh...@riverace.com> on 2008/10/10 17:04:22 UTC

C++ - Question on how to handle logging options for Linux/Windows

Hi folks,

In working the Windows port of the C++ code, some command line options
need some work. Particularly in the case at hand, there are

  --log-output FILE (stderr)              Send log output to FILE.
FILE can be
                                          a file name or one of the
special
                                          values:
                                          stderr, stdout, syslog

  --syslog-name NAME (lt-qpidd)           Name to use in syslog
messages
  --syslog-facility LOG_XXX (LOG_DAEMON)  Facility to use in syslog
messages

To date, the approach I've been working on is to split the options
into common and platform-specific ones. This would make it relatively
easy to build in only the ones needed. For example, the syslog stuff
is not pertinent to Windows, but event logging options would be.

The issue at hand is the --log-output option because its values are
split between portable (stderr, stdout, filename) and
platform-specific (syslog).

I see two ways to handle this, and I am asking for your discussion and
advice.

1. Remove the 'syslog' value from --log-output and add a new option to
the platform-specific set; maybe --log-syslog yes|no

2. Leave the options as they are and specialize just the syslog
handling inside the code.

3. Don't try to split into common and platform-specific options; just
maintain completely separate option sets for each platform even though
90% of the code will be identical. At least to start...

I think #1 is the better way to go since it puts the output sink
option with the platform-specific things. You could argue that
"--log-output syslog" could be interpreted as "event log" on Windows,
but that is stretching it a  bit and the plan wouldn't carry to future
platforms (of which there certainly will be some!) which don't offer
any sort of syslog-like capability.

Thoughts?

-Steve


RE: C++ - Question on how to handle logging options forLinux/Windows

Posted by Alan Conway <ac...@redhat.com>.
On Tue, 2008-10-14 at 20:04 -0400, Steve Huston wrote:
> Hi Alan,
> 
> > > A like the plugin sort of idea, but I can't justify the 
> > effort at this
> > > point getting ready for M4. I am going to move the 
> > --log-output to the
> > > platform-specific options. We can revisit this at a later point if
> > > there's further interest or problems.
> > 
> > I like the plugin idea too, and in retrospect I think Andrew's right
> > about --log-output being an unfortunate mix. I'd suggest 
> > something like
> > this: drop --log-output and have sink-specific options like
> >  --log-to-stderr yes|no
> >  --log-to-file <filename>
> >  --log-to-syslog yes|no
> >    ( and related --syslog options)
> >  --log-to-eventlog (eventlog parameters?)
> >    (and related --eventlog options)
> 
> Ok, that makes sense... And with two more-senior folks advocating, I'm
> convinced.
> 
> > Sinks with simple config like file or stderr can be completely
> > configured with a single option. More complicated sinks like
> > syslog/eventlog can have additional configuration options.
> > Everything related to a given type of sink can be included/excluded
> by
> > including/excluding options, not need to additionally manage the
> > behavior of a "shared" option like --log-output.
> > 
> > Steve, I'm OK with you going around the problem for now by making
> > --log-output system specific, but could you raise a JIRA based on
> this
> > discussion so we don't lose the good intention to refactor? 
> > Making this
> > pluggable will be straightforward once we've reorganized
> sink-related
> > options into dijoint sets.
> 
> Ok, here's how it will look when I check these in:
> 
>  ./qpidd --help
> Usage: qpidd [OPTIONS]
> 
> <all non-logging output is the same, so not included here>
> 
> Logging options:
>   -t [ --trace ]                          Enables all logging
>   --log-enable RULE (error+)              Enables logging for selected
> levels
>                                           and components. RULE is in
> the form
>                                           'LEVEL[+][:PATTERN]' Levels
> are one
>                                           of:
>                                            trace debug info notice
> warning
>                                           error critical
>                                           For example:
>                                           '--log-enable warning+' logs
> all
>                                           warning, error and critical
> messages.
>                                           '--log-enable debug:framing'
> logs
>                                           debug messages from the
> framing
>                                           namespace. This option can
> be used
>                                           multiple times
>   --log-time yes|no (1)                   Include time in log messages
>   --log-level yes|no (1)                  Include severity level in
> log
>                                           messages
>   --log-source yes|no (0)                 Include source file:line in
> log
>                                           messages
>   --log-thread yes|no (0)                 Include thread ID in log
> messages
>   --log-function yes|no (0)               Include function signature
> in log
>                                           messages
>   --log-prefix STRING                     Prefix to append to all log
> messages
> 
> Logging sink options:
>   --log-to-stderr yes|no (1)              Send logging output to
> stderr
>   --log-to-stdout yes|no (0)              Send logging output to
> stdout
>   --log-to-file FILE                      Send log output to FILE.
>   --log-to-syslog yes|no (0)              Send logging output to
> syslog;
>                                           customize using
> --syslog-name and
>                                           --syslog-facility
>   --syslog-name NAME (lt-qpidd)           Name to use in syslog
> messages
>   --syslog-facility LOG_XXX (LOG_DAEMON)  Facility to use in syslog
> messages
> 
> 
> On Windows, the logging sink options will be different.
> 
> I'm going to go with this unless there are screams of outrage.
> 
> Thanks for your input... I really appreciate having more experienced
> folks review things.
> 
> -Steve
> 

That sounds spot-on to me. 



RE: C++ - Question on how to handle logging options forLinux/Windows

Posted by Steve Huston <sh...@riverace.com>.
Hi Alan,

> > A like the plugin sort of idea, but I can't justify the 
> effort at this
> > point getting ready for M4. I am going to move the 
> --log-output to the
> > platform-specific options. We can revisit this at a later point if
> > there's further interest or problems.
> 
> I like the plugin idea too, and in retrospect I think Andrew's right
> about --log-output being an unfortunate mix. I'd suggest 
> something like
> this: drop --log-output and have sink-specific options like
>  --log-to-stderr yes|no
>  --log-to-file <filename>
>  --log-to-syslog yes|no
>    ( and related --syslog options)
>  --log-to-eventlog (eventlog parameters?)
>    (and related --eventlog options)

Ok, that makes sense... And with two more-senior folks advocating, I'm
convinced.

> Sinks with simple config like file or stderr can be completely
> configured with a single option. More complicated sinks like
> syslog/eventlog can have additional configuration options.
> Everything related to a given type of sink can be included/excluded
by
> including/excluding options, not need to additionally manage the
> behavior of a "shared" option like --log-output.
> 
> Steve, I'm OK with you going around the problem for now by making
> --log-output system specific, but could you raise a JIRA based on
this
> discussion so we don't lose the good intention to refactor? 
> Making this
> pluggable will be straightforward once we've reorganized
sink-related
> options into dijoint sets.

Ok, here's how it will look when I check these in:

 ./qpidd --help
Usage: qpidd [OPTIONS]

<all non-logging output is the same, so not included here>

Logging options:
  -t [ --trace ]                          Enables all logging
  --log-enable RULE (error+)              Enables logging for selected
levels
                                          and components. RULE is in
the form
                                          'LEVEL[+][:PATTERN]' Levels
are one
                                          of:
                                           trace debug info notice
warning
                                          error critical
                                          For example:
                                          '--log-enable warning+' logs
all
                                          warning, error and critical
messages.
                                          '--log-enable debug:framing'
logs
                                          debug messages from the
framing
                                          namespace. This option can
be used
                                          multiple times
  --log-time yes|no (1)                   Include time in log messages
  --log-level yes|no (1)                  Include severity level in
log
                                          messages
  --log-source yes|no (0)                 Include source file:line in
log
                                          messages
  --log-thread yes|no (0)                 Include thread ID in log
messages
  --log-function yes|no (0)               Include function signature
in log
                                          messages
  --log-prefix STRING                     Prefix to append to all log
messages

Logging sink options:
  --log-to-stderr yes|no (1)              Send logging output to
stderr
  --log-to-stdout yes|no (0)              Send logging output to
stdout
  --log-to-file FILE                      Send log output to FILE.
  --log-to-syslog yes|no (0)              Send logging output to
syslog;
                                          customize using
--syslog-name and
                                          --syslog-facility
  --syslog-name NAME (lt-qpidd)           Name to use in syslog
messages
  --syslog-facility LOG_XXX (LOG_DAEMON)  Facility to use in syslog
messages


On Windows, the logging sink options will be different.

I'm going to go with this unless there are screams of outrage.

Thanks for your input... I really appreciate having more experienced
folks review things.

-Steve


RE: C++ - Question on how to handle logging options for Linux/Windows

Posted by Alan Conway <ac...@redhat.com>.
On Mon, 2008-10-13 at 15:21 -0400, Steve Huston wrote:
> Hi folks,
> 
> Thanks for the input on the logging question.
> 
> > From: Carl Trieloff [mailto:cctrieloff@redhat.com] 
> >  From a user perspective, this is what I would want to see.
> > 
> > On Linux --log-output has options of
> > 
> > stderr, stdout, syslog
> > 
> > On Windows --log-output has options of
> > 
> > stderr, stdout, eventlog
> > 
> > Then on Linux, the
> > 
> >   --syslog-name NAME (lt-qpidd)           Name to use in syslog
> > messages
> >   --syslog-facility LOG_XXX (LOG_DAEMON)  Facility to use in syslog
> > messages
> > 
> > options appear in the list where they are.
> > 
> > and on Windows
> > 
> > any options for event-log are added.
> 
> This sounds good.
> 
> > From: Andrew Stitcher [mailto:astitcher@redhat.com] 
> > On Fri, 2008-10-10 at 11:04 -0400, Steve Huston wrote:
> > > ...
> > > I see two ways to handle this, and I am asking for your 
> > discussion and
> > > advice.
> > > 
> > > 1. Remove the 'syslog' value from --log-output and add a 
> > new option to
> > > the platform-specific set; maybe --log-syslog yes|no
> > > 
> > > 2. Leave the options as they are and specialize just the syslog
> > > handling inside the code.
> > > 
> > > 3. Don't try to split into common and platform-specific 
> > options; just
> > > maintain completely separate option sets for each platform 
> > even though
> > > 90% of the code will be identical. At least to start...
> > 
> > I think I'd personally prefer a slightly different approach (well a
> > variant on #1 I suppose): Introduce a new option which is an
> explicit
> > logging sink.
> > 
> > The essential problem with the current command line interface 
> > is that it
> > overloads the filename with stuff not related to files at all. So
> what
> > I'd suggest is something like an extra option to direct 
> > logging output.
> > 
> > Something like:
> > 
> > --log-to <logfile | syslog | eventlog | ...>
> > 
> > then change the option name a bit for consistency with the log-to
> > option:
> 
> This sort of rearranges the problem - I think you're on to something
> with the comment that mixing generic and specific logging sink names
> is a bit problematic, but I'm nto really up for rearranging things at
> this point - I have a big hunk of Windows things to get in before I
> can rework too much existing (and working) code.
> 
> > --logfile-out FILE (...)
> > 
> > Actually I'm not 100% we really need option to redirect the syslog
> > output, but that's a different discussion.
> > 
> > I'd guess this might be most easily implemented by 
> > introducing a plugin type architcture for log sinks.
> 
> A like the plugin sort of idea, but I can't justify the effort at this
> point getting ready for M4. I am going to move the --log-output to the
> platform-specific options. We can revisit this at a later point if
> there's further interest or problems.

I like the plugin idea too, and in retrospect I think Andrew's right
about --log-output being an unfortunate mix. I'd suggest something like
this: drop --log-output and have sink-specific options like
 --log-to-stderr yes|no
 --log-to-file <filename>
 --log-to-syslog yes|no
   ( and related --syslog options)
 --log-to-eventlog (eventlog parameters?)
   (and related --eventlog options)

Sinks with simple config like file or stderr can be completely
configured with a single option. More complicated sinks like
syslog/eventlog can have additional configuration options.
Everything related to a given type of sink can be included/excluded by
including/excluding options, not need to additionally manage the
behavior of a "shared" option like --log-output.

Steve, I'm OK with you going around the problem for now by making
--log-output system specific, but could you raise a JIRA based on this
discussion so we don't lose the good intention to refactor? Making this
pluggable will be straightforward once we've reorganized sink-related
options into dijoint sets.

Cheers,
Alan.


RE: C++ - Question on how to handle logging options for Linux/Windows

Posted by Steve Huston <sh...@riverace.com>.
Hi folks,

Thanks for the input on the logging question.

> From: Carl Trieloff [mailto:cctrieloff@redhat.com] 
>  From a user perspective, this is what I would want to see.
> 
> On Linux --log-output has options of
> 
> stderr, stdout, syslog
> 
> On Windows --log-output has options of
> 
> stderr, stdout, eventlog
> 
> Then on Linux, the
> 
>   --syslog-name NAME (lt-qpidd)           Name to use in syslog
> messages
>   --syslog-facility LOG_XXX (LOG_DAEMON)  Facility to use in syslog
> messages
> 
> options appear in the list where they are.
> 
> and on Windows
> 
> any options for event-log are added.

This sounds good.

> From: Andrew Stitcher [mailto:astitcher@redhat.com] 
> On Fri, 2008-10-10 at 11:04 -0400, Steve Huston wrote:
> > ...
> > I see two ways to handle this, and I am asking for your 
> discussion and
> > advice.
> > 
> > 1. Remove the 'syslog' value from --log-output and add a 
> new option to
> > the platform-specific set; maybe --log-syslog yes|no
> > 
> > 2. Leave the options as they are and specialize just the syslog
> > handling inside the code.
> > 
> > 3. Don't try to split into common and platform-specific 
> options; just
> > maintain completely separate option sets for each platform 
> even though
> > 90% of the code will be identical. At least to start...
> 
> I think I'd personally prefer a slightly different approach (well a
> variant on #1 I suppose): Introduce a new option which is an
explicit
> logging sink.
> 
> The essential problem with the current command line interface 
> is that it
> overloads the filename with stuff not related to files at all. So
what
> I'd suggest is something like an extra option to direct 
> logging output.
> 
> Something like:
> 
> --log-to <logfile | syslog | eventlog | ...>
> 
> then change the option name a bit for consistency with the log-to
> option:

This sort of rearranges the problem - I think you're on to something
with the comment that mixing generic and specific logging sink names
is a bit problematic, but I'm nto really up for rearranging things at
this point - I have a big hunk of Windows things to get in before I
can rework too much existing (and working) code.

> --logfile-out FILE (...)
> 
> Actually I'm not 100% we really need option to redirect the syslog
> output, but that's a different discussion.
> 
> I'd guess this might be most easily implemented by 
> introducing a plugin type architcture for log sinks.

A like the plugin sort of idea, but I can't justify the effort at this
point getting ready for M4. I am going to move the --log-output to the
platform-specific options. We can revisit this at a later point if
there's further interest or problems.

Thanks!
-Steve


Re: C++ - Question on how to handle logging options for Linux/Windows

Posted by Carl Trieloff <cc...@redhat.com>.
 From a user perspective, this is what I would want to see.

On Linux --log-output has options of

stderr, stdout, syslog


On Windows --log-output has options of

stderr, stdout, eventlog



Then on Linux, the

  --syslog-name NAME (lt-qpidd)           Name to use in syslog
messages
  --syslog-facility LOG_XXX (LOG_DAEMON)  Facility to use in syslog
messages


options appear in the list where they are.


and on Windows

any options for event-log are added.


If the code is 90% the same for linux and windows as you say, I would 
hide the handling and
string printing etc into platform specific classes, with all the common 
functionality in a base class

Andrew/ Alan might have a different idea on how to implement it.

Carl.


Steve Huston wrote:
> Hi folks,
>
> In working the Windows port of the C++ code, some command line options
> need some work. Particularly in the case at hand, there are
>
>   --log-output FILE (stderr)              Send log output to FILE.
> FILE can be
>                                           a file name or one of the
> special
>                                           values:
>                                           stderr, stdout, syslog
>
>   --syslog-name NAME (lt-qpidd)           Name to use in syslog
> messages
>   --syslog-facility LOG_XXX (LOG_DAEMON)  Facility to use in syslog
> messages
>
> To date, the approach I've been working on is to split the options
> into common and platform-specific ones. This would make it relatively
> easy to build in only the ones needed. For example, the syslog stuff
> is not pertinent to Windows, but event logging options would be.
>
> The issue at hand is the --log-output option because its values are
> split between portable (stderr, stdout, filename) and
> platform-specific (syslog).
>
> I see two ways to handle this, and I am asking for your discussion and
> advice.
>
> 1. Remove the 'syslog' value from --log-output and add a new option to
> the platform-specific set; maybe --log-syslog yes|no
>
> 2. Leave the options as they are and specialize just the syslog
> handling inside the code.
>
> 3. Don't try to split into common and platform-specific options; just
> maintain completely separate option sets for each platform even though
> 90% of the code will be identical. At least to start...
>
> I think #1 is the better way to go since it puts the output sink
> option with the platform-specific things. You could argue that
> "--log-output syslog" could be interpreted as "event log" on Windows,
> but that is stretching it a  bit and the plan wouldn't carry to future
> platforms (of which there certainly will be some!) which don't offer
> any sort of syslog-like capability.
>
> Thoughts?
>
> -Steve
>
>   


Re: C++ - Question on how to handle logging options for Linux/Windows

Posted by Andrew Stitcher <as...@redhat.com>.
On Fri, 2008-10-10 at 11:04 -0400, Steve Huston wrote:
> ...
> I see two ways to handle this, and I am asking for your discussion and
> advice.
> 
> 1. Remove the 'syslog' value from --log-output and add a new option to
> the platform-specific set; maybe --log-syslog yes|no
> 
> 2. Leave the options as they are and specialize just the syslog
> handling inside the code.
> 
> 3. Don't try to split into common and platform-specific options; just
> maintain completely separate option sets for each platform even though
> 90% of the code will be identical. At least to start...

I think I'd personally prefer a slightly different approach (well a
variant on #1 I suppose): Introduce a new option which is an explicit
logging sink.

The essential problem with the current command line interface is that it
overloads the filename with stuff not related to files at all. So what
I'd suggest is something like an extra option to direct logging output.

Something like:

--log-to <logfile | syslog | eventlog | ...>

then change the option name a bit for consistency with the log-to
option:

--logfile-out FILE (...)

Actually I'm not 100% we really need option to redirect the syslog
output, but that's a different discussion.

I'd guess this might be most easily implemented by introducing a plugin
type architcture for log sinks.

Does anyone else have comments?