Skip to content

Commit 53045c1

Browse files
author
Matthew Fisher
committed
Merge pull request #3188 from bacongobbler/3063-fix-log-format
fix(controller): do not log to app in log_event
2 parents a25a20b + c698a98 commit 53045c1

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

controller/api/models.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ def _close_db_connections(*args, **kwargs):
5757

5858

5959
def log_event(app, msg, level=logging.INFO):
60-
msg = "{}: {}".format(app.id, msg)
61-
logger.log(level, msg) # django logger
62-
app.log(msg) # local filesystem
60+
# controller needs to know which app this log comes from
61+
logger.log(level, "{}: {}".format(app.id, msg))
62+
app.log(msg)
6363

6464

6565
def validate_base64(value):
@@ -680,7 +680,7 @@ def new(self, user, config, build, summary=None, source_version='latest'):
680680
release.publish()
681681
except EnvironmentError as e:
682682
# If we cannot publish this app, just log and carry on
683-
logger.info(e)
683+
log_event(self.app, e)
684684
pass
685685
return release
686686

@@ -847,36 +847,35 @@ def __str__(self):
847847
def _log_build_created(**kwargs):
848848
if kwargs.get('created'):
849849
build = kwargs['instance']
850-
log_event(build.app, "build {} created".format(build))
850+
# log only to the controller; this event will be logged in the release summary
851+
logger.info("{}: build {} created".format(build.app, build))
851852

852853

853854
def _log_release_created(**kwargs):
854855
if kwargs.get('created'):
855856
release = kwargs['instance']
856-
log_event(release.app, "release {} created".format(release))
857+
# log only to the controller; this event will be logged in the release summary
858+
logger.info("{}: release {} created".format(release.app, release))
857859
# append release lifecycle logs to the app
858860
release.app.log(release.summary)
859861

860862

861863
def _log_config_updated(**kwargs):
862864
config = kwargs['instance']
863-
log_event(config.app, "config {} updated".format(config))
865+
# log only to the controller; this event will be logged in the release summary
866+
logger.info("{}: config {} updated".format(config.app, config))
864867

865868

866869
def _log_domain_added(**kwargs):
867870
domain = kwargs['instance']
868871
msg = "domain {} added".format(domain)
869872
log_event(domain.app, msg)
870-
# adding a domain does not create a release, so we have to log here
871-
domain.app.log(msg)
872873

873874

874875
def _log_domain_removed(**kwargs):
875876
domain = kwargs['instance']
876877
msg = "domain {} removed".format(domain)
877878
log_event(domain.app, msg)
878-
# adding a domain does not create a release, so we have to log here
879-
domain.app.log(msg)
880879

881880

882881
def _etcd_publish_key(**kwargs):

0 commit comments

Comments
 (0)