66import abc
77import dataclasses
88import logging
9- import traceback
109import typing
1110
1211from frequenz .channels import Broadcast , Receiver
@@ -140,13 +139,9 @@ def get_or_create(self, message_type: type[T], key: str) -> Broadcast[T]:
140139 ValueError: If the channel exists and the message type does not match.
141140 """
142141 if key not in self ._channels :
143- if _logger .isEnabledFor (logging .DEBUG ):
144- _logger .debug (
145- "Creating a new channel for key %r with type %s at:\n %s" ,
146- key ,
147- message_type ,
148- "" .join (traceback .format_stack (limit = 10 )[:9 ]),
149- )
142+ _logger .debug (
143+ "Creating a new channel for key %r with type %s." , key , message_type
144+ )
150145 self ._channels [key ] = _Entry (
151146 message_type , Broadcast (name = f"{ self ._name } -{ key } " )
152147 )
@@ -158,14 +153,7 @@ def get_or_create(self, message_type: type[T], key: str) -> Broadcast[T]:
158153 f"message type { message_type } is not the same as the existing "
159154 f"message type { entry .message_type } ."
160155 )
161- if _logger .isEnabledFor (logging .DEBUG ):
162- _logger .debug (
163- "%s at:\n %s" ,
164- error_message ,
165- # We skip the last frame because it's this method, and limit the
166- # stack to 9 frames to avoid adding too much noise.
167- "" .join (traceback .format_stack (limit = 10 )[:9 ]),
168- )
156+ _logger .debug ("%s" , error_message )
169157 raise ValueError (error_message )
170158
171159 return typing .cast (Broadcast [T ], entry .channel )
0 commit comments