Skip to content

Commit 2c24a17

Browse files
committed
chore: simple reproduction example
Signed-off-by: Dariusz Duda <dariusz.duda@canonical.com>
1 parent 1026c43 commit 2c24a17

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

examples.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -521,21 +521,20 @@ def example_31():
521521
time.sleep(6)
522522
raise CraftError("Error 1\nError 2")
523523

524+
524525
def example_32():
525526
"""Logger affects emitter."""
526-
logger = logging.getLogger("test")
527+
logger = logging.getLogger()
528+
# This doesn't work (streaming_brief=True)
529+
emit.init(EmitterMode.BRIEF, "explorator", "Greetings earthlings", streaming_brief=True)
530+
# This works
531+
# emit.init(EmitterMode.BRIEF, "explorator", "Greetings earthlings")
527532
logger.setLevel(logging.DEBUG)
528-
logger.addHandler(logging.StreamHandler())
529-
# emit.set_mode(EmitterMode.BRIEF)
530533

531-
emit.progress("Shorter message")
532-
logger.debug("Message from external logger 1")
533-
emit.progress("Another message")
534-
time.sleep(1)
535-
emit.progress("Interminient message", permanent=True)
536-
logger.debug("Message from external logger 2")
537-
time.sleep(1)
538-
emit.message("Final message")
534+
# it fails only if following message is multiline
535+
logger.info("Message from external logger 2")
536+
emit.message("Final message\nMultiline")
537+
539538

540539
# -- end of test cases
541540

@@ -549,7 +548,7 @@ def example_32():
549548
print(f"ERROR: function {name!r} not found")
550549
exit()
551550

552-
if int(sys.argv[1]) != 29:
551+
if int(sys.argv[1]) not in (29, 32):
553552
emit.init(EmitterMode.BRIEF, "explorator", "Greetings earthlings")
554553
try:
555554
func(*sys.argv[2:])

0 commit comments

Comments
 (0)