@@ -43,6 +43,17 @@ def __str__(self):
4343 def image (self ):
4444 return self .build .image
4545
46+ def log (self , message , level = logging .INFO ):
47+ """Logs a message in the context of this application.
48+
49+ This prefixes log messages with an application "tag" that the customized
50+ drycc-logspout will be on the lookout for. When it's seen, the message-- usually
51+ an application event of some sort like releasing or scaling, will be considered
52+ as "belonging" to the application instead of the controller and will be handled
53+ accordingly.
54+ """
55+ logger .log (level , "[{}]: {}" .format (self .app .id , message ))
56+
4657 def new (self , user , config , build , summary = None , canary = False ):
4758 """
4859 Create a new application release using the provided Build and Config
@@ -69,7 +80,7 @@ def get_port(self):
6980 creds = self .get_registry_auth ()
7081
7182 if self .build .type == "buildpack" :
72- self .app . log (
83+ self .log (
7384 'buildpack type detected. Defaulting to $PORT %s' % DEFAULT_CONTAINER_PORT )
7485 return DEFAULT_CONTAINER_PORT
7586
@@ -172,7 +183,7 @@ def cleanup_old(self): # noqa
172183 Stray pods no longer relevant to the latest release
173184 """
174185 latest_version = 'v{}' .format (self .version )
175- self .app . log (
186+ self .log (
176187 'Cleaning up RSs for releases older than {} (latest)' .format (latest_version ),
177188 level = logging .DEBUG
178189 )
@@ -194,7 +205,7 @@ def cleanup_old(self): # noqa
194205 replica_sets_removal .append (current_version )
195206
196207 if replica_sets_removal :
197- self .app . log (
208+ self .log (
198209 'Found the following versions to cleanup: {}' .format (', ' .join (replica_sets_removal )), # noqa
199210 level = logging .DEBUG
200211 )
@@ -260,7 +271,7 @@ def _cleanup_deployment_secrets_and_configs(self, namespace):
260271 # http://kubernetes.io/docs/user-guide/labels/#set-based-requirement
261272 'version__notin' : versions
262273 }
263- self .app . log ('Cleaning up orphaned env var secrets for application {}' .format (namespace ), level = logging .DEBUG ) # noqa
274+ self .log ('Cleaning up orphaned env var secrets for application {}' .format (namespace ), level = logging .DEBUG ) # noqa
264275 secrets = self .scheduler ().secret .get (namespace , labels = labels ).json ()['items' ]
265276 if not secrets :
266277 secrets = []
0 commit comments