scr icon indicating copy to clipboard operation
scr copied to clipboard

Discussion: Level of logging to expose in Spack package

Open CamStan opened this issue 4 years ago • 3 comments

@adammoody, after reading your email, am I correct in interpreting that SCR_LOG_SYSLOG_FACILITY, SCR_LOG_SYSLOG_LEVEL, and SCR_LOG_SYSLOG_PREFIX are the only options that have to be set at configure time, if wanting to use them at some point? For example, if you set just those three at configure time, can you then set SCR_LOG_ENABLE=1 and SCR_LOG_SYSLOG_ENABLE=1 in scr.conf and the syslog messages will work?


Assuming the three syslog options mentioned above are the only ones that have to be set at configure time in order to be used, then minimally, all we'd need to do is expose variants for each of those and set them to defaults if not provided (our CMakeLists.txt already does this).

If we do want to expose the other logging options, here are my initial thoughts on what/how to expose (open to suggestions on variant/value names):

We could create a variant for each type of LOG_ENABLE option, but figured a multi-value variant of logging might work better. This could use Spack's any_combination_of() function, or we could add an all options and maybe use their disjoint_sets() function to allow either all, or any combination of the logging options. Haven't played with this yet. E.g.:

variant(
    'logging',
    values=any_combination_of('txt', 'syslog', 'db')
)

or

variant(
    'logging',
    values=disjoint_sets(('all',), ('txt', 'syslog', 'db'))
)

Then when handling each of these:


If logging.values not empty (or potentially not none), then in cmake_args() in spackage:

  • Set -DSCR_LOG_ENABLE=1

If txt in logging.values, then in cmake_args() in spackage:

  • Set -DSCR_LOG_TXT_ENABLE=1

If syslog in logging.values, then in cmake_args() in spackage: - Set -DSCR_LOG_SYSLOG_ENABLE=1 - Set FACILITY, LEVEL and PREFIX to default values if variants for each are not provided

Variants for each syslog option:

  • Set SCR_LOG_SYSLOG_FACILITY via syslog-facility=<value>
  • Set SCR_LOG_SYSLOG_LEVEL via syslog-level=<value>
  • Set SCR_LOG_SYSLOG_PREFIX via syslog-prefix=<value>
    • For each of these,
      • Set the associated config option
      • If logging variant isn't set, (i.e, left as none), do we want to:
        • do nothing else since, as mentioned above, they potentially can still enable the logging via scr.conf?
        • set -DSCR_LOG_ENABLE=1 and -DSCR_LOG_SYSLOG_ENABLE=1 for them?
        • require that logging is also set and syslog is in logging.values when setting any of these and ignore these if not?

At first glance, it seems that all of the SCR_LOG_DB options are set using scr.conf, as they are not exposed in CMakeLists.txt, is that correct? If so, then:

If db in logging.values:

  • Just need to set dependency on MySQL

If using an all option for logging then enable everything and use default values for facility/level/prefix unless the variants to set them are provided as well.

CamStan avatar Apr 27 '21 22:04 CamStan

@CamStan , really nice write up!

I like all of your suggestions here.

For the case on setting syslog parameters, let's go with this option:

If logging variant isn't set, (i.e, left as none),
    do nothing else since, as mentioned above, they potentially can still enable the logging via scr.conf

adammoody avatar May 02 '21 18:05 adammoody

@adammoody, I've been looking over the logging options again to decide what to expose through the spack package.

Currently SCR's cmake sets defaults for logging, which still get set when installing via spack. So with no logging exposed in the spackage, spack install scr results in:

-- SCR_LOG_ENABLE: 0
-- SCR_LOG_TXT_ENABLE: 1
-- SCR_LOG_SYSLOG_ENABLE: 1
-- SCR_LOG_SYSLOG_PREFIX: SCR
-- SCR_LOG_SYSLOG_FACILITY: LOG_LOCAL7
-- SCR_LOG_SYSLOG_LEVEL: LOG_INFO

Note: Unless any of these are explicitly overridden in the spack package, their cmake default will still take effect.

Since the ENABLE flags can be changed with environment variables or scr.conf after the build, these don't need to be exposed in spack (unless for convenience it'll help to build with SCR_LOG_ENABLE=1 already set for users).

As established at the top of this issue, SCR_LOG_SYSLOG_[FACILITY|LEVEL|PREFIX] are the only options that have to be set at configure time. However, since these defaults will get set without being exposed via spack then this requirement is met and one could argue that there's no need for them in the spackage either.

So at a minimum, we'd just need a variant to request building with mysql if the user wants to use SCR_LOG_DB logging:

variant('mysql-logs', when=False, description='Record syslogs in MySQL database')
depends_on('mysql', when='+mysql-logs')

Anything else the user would want to enable/set can then be done after installing.


That said, do we expect users will need/want to alter the defaults for SCR_LOG_SYSLOG_[FACILITY|LEVEL|PREFIX]? If so, then we'd need variants for those as well.

CamStan avatar Oct 29 '21 00:10 CamStan

Alternatively, if we're wanting to fully expose all logging options at build time via spack, then ignore that last comment and I'll implement what was previously discussed. 😄

CamStan avatar Oct 29 '21 00:10 CamStan