Michal Kobus | e7589f7 | 2020-09-11 14:29:37 +0200 | [diff] [blame] | 1 | import os |
| 2 | |
Ryan Zhang | 532052d | 2022-05-09 10:23:34 -0700 | [diff] [blame] | 3 | from ..helpers import is_true, get_env_or_secret |
Michal Kobus | 2e85ef8 | 2021-06-24 18:01:43 +0200 | [diff] [blame] | 4 | |
| 5 | |
Michal Kobus | 819cf02 | 2018-11-29 16:39:22 +0100 | [diff] [blame] | 6 | VERSION = 'production' |
| 7 | |
Michal Kobus | 17726ae | 2018-11-27 12:59:55 +0100 | [diff] [blame] | 8 | LOGGING = { |
| 9 | 'version': 1, |
| 10 | 'formatters': {'default': { |
| 11 | 'format': '[%(asctime)s] %(levelname)s in %(module)s: %(message)s', |
| 12 | }}, |
| 13 | 'handlers': { |
| 14 | 'wsgi': { |
| 15 | 'class': 'logging.StreamHandler', |
| 16 | 'stream': 'ext://flask.logging.wsgi_errors_stream', |
| 17 | 'formatter': 'default' |
| 18 | }, |
| 19 | 'file': { |
| 20 | 'class': 'logging.handlers.RotatingFileHandler', |
| 21 | 'formatter': 'default', |
Michal Kobus | 2e85ef8 | 2021-06-24 18:01:43 +0200 | [diff] [blame] | 22 | 'filename': os.getenv('LOGPATH', |
| 23 | '/var/log/sf-notifier/sfnotifier.log'), |
Michal Kobus | 17726ae | 2018-11-27 12:59:55 +0100 | [diff] [blame] | 24 | 'mode': 'a', |
| 25 | 'maxBytes': 10485760, |
| 26 | 'backupCount': 5 |
| 27 | } |
| 28 | }, |
| 29 | 'loggers': { |
Ksawery Dziekoński | 3861b93 | 2021-05-27 14:01:44 +0200 | [diff] [blame] | 30 | logger: { |
| 31 | 'level': os.getenv('LOGGER_LEVEL', 'INFO').upper(), |
Michal Kobus | 17726ae | 2018-11-27 12:59:55 +0100 | [diff] [blame] | 32 | 'handlers': ['file', 'wsgi'] |
Ksawery Dziekoński | 3861b93 | 2021-05-27 14:01:44 +0200 | [diff] [blame] | 33 | } for logger in ['sf_notifier.server', 'sf_notifier.salesforce.client'] |
Michal Kobus | 17726ae | 2018-11-27 12:59:55 +0100 | [diff] [blame] | 34 | } |
| 35 | } |
| 36 | |
| 37 | SIMPLE_SETTINGS = { |
| 38 | 'OVERRIDE_BY_ENV': True, |
| 39 | 'CONFIGURE_LOGGING': True, |
| 40 | } |
| 41 | |
Michal Kobus | 2e85ef8 | 2021-06-24 18:01:43 +0200 | [diff] [blame] | 42 | ADD_LINKS = is_true(os.environ.get('SF_NOTIFIER_ADD_LINKS')) |
Michal Kobus | 28b37f9 | 2022-06-14 11:06:24 +0200 | [diff] [blame] | 43 | CLUSTER_ID = os.environ.get('SF_NOTIFIER_CLUSTER_ID') |
Michal Kobus | e7589f7 | 2020-09-11 14:29:37 +0200 | [diff] [blame] | 44 | |
Michal Kobus | 2e85ef8 | 2021-06-24 18:01:43 +0200 | [diff] [blame] | 45 | SF_CONFIG = { |
| 46 | # Salesforce login params |
| 47 | 'AUTH_URL': os.environ.get('SFDC_AUTH_URL', 'null'), |
Ryan Zhang | 532052d | 2022-05-09 10:23:34 -0700 | [diff] [blame] | 48 | 'USERNAME': get_env_or_secret('SFDC_USERNAME', 'sfdc_username'), |
| 49 | 'PASSWORD': get_env_or_secret('SFDC_PASSWORD', 'sfdc_password'), |
Michal Kobus | 2e85ef8 | 2021-06-24 18:01:43 +0200 | [diff] [blame] | 50 | 'ORGANIZATION_ID': os.environ.get('SFDC_ORGANIZATION_ID', 'null'), |
Ryan Zhang | 532052d | 2022-05-09 10:23:34 -0700 | [diff] [blame] | 51 | 'ENVIRONMENT_ID': get_env_or_secret('SFDC_ENVIRONMENT_ID', 'sfdc_environment_id'), |
Michal Kobus | 2e85ef8 | 2021-06-24 18:01:43 +0200 | [diff] [blame] | 52 | 'SANDBOX_ENABLED': is_true(os.environ.get( |
| 53 | 'SFDC_SANDBOX_ENABLED', 'False')), |
| 54 | # sf-notifier specific params |
| 55 | 'FEED_ENABLED': is_true(os.environ.get( |
| 56 | 'SF_NOTIFIER_FEED_ENABLED', 'True')), |
| 57 | 'HASH_FUNC': os.environ.get( |
| 58 | 'SF_NOTIFIER_ALERT_ID_HASH_FUNC', 'sha256'), |
| 59 | } |