silverstripe / silverstripe-raygun

Raygun.com integration for PHP
BSD 3-Clause "New" or "Revised" License
6 stars 23 forks source link

FEATURE: Env-specific logging #14

Closed phptek closed 8 years ago

phptek commented 10 years ago

Currently, the module isn't picky about what it reports or from where. The former is resolved by @chillu's filter example, the latter would be good to allow dev's to optionally enable Raygun logging on a per environment basis.

Yes it's easy to apply ad-hoc project-specific config, but it's messy in mysite/_config.php, so the ability apply something like this in project config would be better:

RaygunLogWriter:
  environment:
    - test
    - live

This would obviously ensure that Raygun logged only in test and live environments. Something like the following in the module's own _config.php (Off the top of my head)

$userDefinedEnvs = Config::inst()->get('RaygunLogWriter', 'environments');
$enableOnLive = Director::isLive() && in_array('live', $userDefinedEnvs);
$enableOnTest = Director::isTest() && in_array('test', $userDefinedEnvs);
$enableOnDev = Director::isDev() && in_array('dev', $userDefinedEnvs);

if(!empty($raygunAPIKey)) {
    // Enable on specific environments
    if(!$enableOnLive || !$enableOnTest || !$enableOnDev) {
        return;
    }
    ....
}
chillu commented 10 years ago

I think it should be the other way around, we already have a way to define env especific configuration in YAML in core. But that means we have to make the SS_Log class accept these configuration keys, which wouldn't be a Raygun specific enhancement. Rough example:

---
Only:
  environment: 'live'
---
SS_Log:
  loggers:
    RaygunLogWriter:
      api_key: 'ABCDEF123456=='
      level: 'SS_Log::WARNING'
sminnee commented 9 years ago

So, I would have thought that 19ff8ae24d6d7380bd7e627252cfb1c27bf9c8c2 allows for this; I'm a bit confused as to why it doesn't?

Failing that, it also supports an _ss_environment.php value.

chillu commented 8 years ago

Yeah, so as Sam says, that's already possible - closing.