std-mel 0.10.1

Mélodium standard library
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
use root/engine::Engine
use root/engine/log::|debug
use root/engine/log::|error
use root/engine/log::|info
use root/engine/log::|trace
use root/engine/log::|warning
use root/engine/log::logBlock
use root/engine/log::logStream
use root/engine/log::logDataBlock
use root/engine/log::logDataStream
use root/engine/log::logBlockLabel
use root/engine/log::logStreamLabel
use root/engine/log::logDataBlockLabel
use root/engine/log::logDataStreamLabel
use root/flow::emit

/**
Log a fixed debug message when triggered.

Emits `message` to the engine log at debug level with the given `label` whenever `trigger` fires.
*/
treatment logDebugMessage(label: string = "debug", message: string)
  model engine: Engine()
  input trigger: Block<void>
{
    emit<string>(value=message)
    logBlock[engine=engine](level = |debug(), label = label)

    Self.trigger -> emit.trigger,emit -> logBlock.message
}

/**
Log a single debug-level message block.

Forwards `message` to the engine log at debug level with the given `label`.
*/
treatment logDebug(label: string = "debug")
  model engine: Engine()
  input message: Block<string>
{
    logBlock[engine=engine](level = |debug(), label = label)

    Self.message -> logBlock.message
}

/**
Log a stream of debug-level messages.

Each string in `messages` is forwarded to the engine log at debug level with the given `label`.
*/
treatment logDebugs(label: string = "debug")
  model engine: Engine()
  input messages: Stream<string>
{
    logStream[engine=engine](level = |debug(), label = label)

    Self.messages -> logStream.messages
}

/**
Log a single displayable value at debug level.

Converts `data` to its display representation and logs it at debug level with the given `label`.
*/
treatment logDataDebug<D: Display>(label: string = "debug")
  model engine: Engine()
  input data: Block<D>
{
    logDataBlock<D>[engine=engine](level = |debug(), label = label)

    Self.data -> logDataBlock.display
}

/**
Log a stream of displayable values at debug level.

Each item in `data` is converted to its display representation and logged at debug level with the given `label`.
*/
treatment logDataDebugs<D: Display>(label: string = "debug")
  model engine: Engine()
  input data: Stream<D>
{
    logDataStream<D>[engine=engine](level = |debug(), label = label)

    Self.data -> logDataStream.display
}

/**
Log a fixed error message when triggered.

Emits `message` to the engine log at error level with the given `label` whenever `trigger` fires.
*/
treatment logErrorMessage(label: string = "error", message: string)
  model engine: Engine()
  input trigger: Block<void>
{
    emit<string>(value=message)
    logBlock[engine=engine](level = |error(), label = label)

    Self.trigger -> emit.trigger,emit -> logBlock.message
}

/**
Log a single error-level message block.

Forwards `message` to the engine log at error level with the given `label`.
*/
treatment logError(label: string = "error")
  model engine: Engine()
  input message: Block<string>
{
    logBlock[engine=engine](level = |error(), label = label)

    Self.message -> logBlock.message
}

/**
Log a stream of error-level messages.

Each string in `messages` is forwarded to the engine log at error level with the given `label`.
*/
treatment logErrors(label: string = "error")
  model engine: Engine()
  input messages: Stream<string>
{
    logStream[engine=engine](level = |error(), label = label)

    Self.messages -> logStream.messages
}

/**
Log a single displayable value at error level.

Converts `data` to its display representation and logs it at error level with the given `label`.
*/
treatment logDataError<D: Display>(label: string = "error")
  model engine: Engine()
  input data: Block<D>
{
    logDataBlock<D>[engine=engine](level = |error(), label = label)

    Self.data -> logDataBlock.display
}

/**
Log a stream of displayable values at error level.

Each item in `data` is converted to its display representation and logged at error level with the given `label`.
*/
treatment logDataErrors<D: Display>(label: string = "error")
  model engine: Engine()
  input data: Stream<D>
{
    logDataStream<D>[engine=engine](level = |error(), label = label)

    Self.data -> logDataStream.display
}

/**
Log a fixed info message when triggered.

Emits `message` to the engine log at info level with the given `label` whenever `trigger` fires.
*/
treatment logInfoMessage(label: string = "info", message: string)
  model engine: Engine()
  input trigger: Block<void>
{
    emit<string>(value=message)
    logBlock[engine=engine](level = |info(), label = label)

    Self.trigger -> emit.trigger,emit -> logBlock.message
}

/**
Log a single info-level message block.

Forwards `message` to the engine log at info level with the given `label`.
*/
treatment logInfo(label: string = "info")
  model engine: Engine()
  input message: Block<string>
{
    logBlock[engine=engine](level = |info(), label = label)

    Self.message -> logBlock.message
}

/**
Log a stream of info-level messages.

Each string in `messages` is forwarded to the engine log at info level with the given `label`.
*/
treatment logInfos(label: string = "info")
  model engine: Engine()
  input messages: Stream<string>
{
    logStream[engine=engine](level = |info(), label = label)

    Self.messages -> logStream.messages
}

/**
Log a single displayable value at info level.

Converts `data` to its display representation and logs it at info level with the given `label`.
*/
treatment logDataInfo<D: Display>(label: string = "info")
  model engine: Engine()
  input data: Block<D>
{
    logDataBlock<D>[engine=engine](level = |info(), label = label)

    Self.data -> logDataBlock.display
}

/**
Log a stream of displayable values at info level.

Each item in `data` is converted to its display representation and logged at info level with the given `label`.
*/
treatment logDataInfos<D: Display>(label: string = "info")
  model engine: Engine()
  input data: Stream<D>
{
    logDataStream<D>[engine=engine](level = |info(), label = label)

    Self.data -> logDataStream.display
}

/**
Log a fixed trace message when triggered.

Emits `message` to the engine log at trace level with the given `label` whenever `trigger` fires.
*/
treatment logTraceMessage(label: string = "trace", message: string)
  model engine: Engine()
  input trigger: Block<void>
{
    emit<string>(value=message)
    logBlock[engine=engine](level = |trace(), label = label)

    Self.trigger -> emit.trigger,emit -> logBlock.message
}

/**
Log a single trace-level message block.

Forwards `message` to the engine log at trace level with the given `label`.
*/
treatment logTrace(label: string = "trace")
  model engine: Engine()
  input message: Block<string>
{
    logBlock[engine=engine](level = |trace(), label = label)

    Self.message -> logBlock.message
}

/**
Log a stream of trace-level messages.

Each string in `messages` is forwarded to the engine log at trace level with the given `label`.
*/
treatment logTraces(label: string = "trace")
  model engine: Engine()
  input messages: Stream<string>
{
    logStream[engine=engine](level = |trace(), label = label)

    Self.messages -> logStream.messages
}

/**
Log a single displayable value at trace level.

Converts `data` to its display representation and logs it at trace level with the given `label`.
*/
treatment logDataTrace<D: Display>(label: string = "trace")
  model engine: Engine()
  input data: Block<D>
{
    logDataBlock<D>[engine=engine](level = |trace(), label = label)

    Self.data -> logDataBlock.display
}

/**
Log a stream of displayable values at trace level.

Each item in `data` is converted to its display representation and logged at trace level with the given `label`.
*/
treatment logDataTraces<D: Display>(label: string = "trace")
  model engine: Engine()
  input data: Stream<D>
{
    logDataStream<D>[engine=engine](level = |trace(), label = label)

    Self.data -> logDataStream.display
}

/**
Log a fixed warning message when triggered.

Emits `message` to the engine log at warning level with the given `label` whenever `trigger` fires.
*/
treatment logWarningMessage(label: string = "warning", message: string)
  model engine: Engine()
  input trigger: Block<void>
{
    emit<string>(value=message)
    logBlock[engine=engine](level = |warning(), label = label)

    Self.trigger -> emit.trigger,emit -> logBlock.message
}

/**
Log a single warning-level message block.

Forwards `message` to the engine log at warning level with the given `label`.
*/
treatment logWarning(label: string = "warning")
  model engine: Engine()
  input message: Block<string>
{
    logBlock[engine=engine](level = |warning(), label = label)

    Self.message -> logBlock.message
}

/**
Log a stream of warning-level messages.

Each string in `messages` is forwarded to the engine log at warning level with the given `label`.
*/
treatment logWarnings(label: string = "warning")
  model engine: Engine()
  input messages: Stream<string>
{
    logStream[engine=engine](level = |warning(), label = label)

    Self.messages -> logStream.messages
}

/**
Log a single displayable value at warning level.

Converts `data` to its display representation and logs it at warning level with the given `label`.
*/
treatment logDataWarning<D: Display>(label: string = "warning")
  model engine: Engine()
  input data: Block<D>
{
    logDataBlock<D>[engine=engine](level = |warning(), label = label)

    Self.data -> logDataBlock.display
}

/**
Log a stream of displayable values at warning level.

Each item in `data` is converted to its display representation and logged at warning level with the given `label`.
*/
treatment logDataWarnings<D: Display>(label: string = "warning")
  model engine: Engine()
  input data: Stream<D>
{
    logDataStream<D>[engine=engine](level = |warning(), label = label)

    Self.data -> logDataStream.display
}

/**
Log a single debug-level message with a streamed label.

Both `label` and `message` are received as blocks, allowing the label to vary at runtime.
*/
treatment logDebugLabel()
  model engine: Engine()
  input label: Block<string>
  input message: Block<string>
{
    logBlockLabel[engine=engine](level = |debug())

    Self.label ---> logBlockLabel.label
    Self.message -> logBlockLabel.message
}

/**
Log a stream of debug-level messages with a streamed label.

`label` is received as a block; each string in `messages` is logged at debug level under that label.
*/
treatment logDebugsLabel()
  model engine: Engine()
  input label: Block<string>
  input messages: Stream<string>
{
    logStreamLabel[engine=engine](level = |debug())

    Self.label ----> logStreamLabel.label
    Self.messages -> logStreamLabel.messages
}

/**
Log a single displayable value at debug level with a streamed label.

Both `label` and `data` are received as blocks; `data` is converted to its display form before logging.
*/
treatment logDataDebugLabel<D: Display>()
  model engine: Engine()
  input label: Block<string>
  input data: Block<D>
{
    logDataBlockLabel<D>[engine=engine](level = |debug())

    Self.label -> logDataBlockLabel.label
    Self.data --> logDataBlockLabel.display
}

/**
Log a stream of displayable values at debug level with a streamed label.

`label` is received as a block; each item in `data` is converted to its display form and logged at debug level.
*/
treatment logDataDebugsLabel<D: Display>()
  model engine: Engine()
  input label: Block<string>
  input data: Stream<D>
{
    logDataStreamLabel<D>[engine=engine](level = |debug())

    Self.label -> logDataStreamLabel.label
    Self.data --> logDataStreamLabel.display
}

/**
Log a single error-level message with a streamed label.

Both `label` and `message` are received as blocks, allowing the label to vary at runtime.
*/
treatment logErrorLabel()
  model engine: Engine()
  input label: Block<string>
  input message: Block<string>
{
    logBlockLabel[engine=engine](level = |error())

    Self.label ---> logBlockLabel.label
    Self.message -> logBlockLabel.message
}

/**
Log a stream of error-level messages with a streamed label.

`label` is received as a block; each string in `messages` is logged at error level under that label.
*/
treatment logErrorsLabel()
  model engine: Engine()
  input label: Block<string>
  input messages: Stream<string>
{
    logStreamLabel[engine=engine](level = |error())

    Self.label ----> logStreamLabel.label
    Self.messages -> logStreamLabel.messages
}

/**
Log a single displayable value at error level with a streamed label.

Both `label` and `data` are received as blocks; `data` is converted to its display form before logging.
*/
treatment logDataErrorLabel<D: Display>()
  model engine: Engine()
  input label: Block<string>
  input data: Block<D>
{
    logDataBlockLabel<D>[engine=engine](level = |error())

    Self.label -> logDataBlockLabel.label
    Self.data --> logDataBlockLabel.display
}

/**
Log a stream of displayable values at error level with a streamed label.

`label` is received as a block; each item in `data` is converted to its display form and logged at error level.
*/
treatment logDataErrorsLabel<D: Display>()
  model engine: Engine()
  input label: Block<string>
  input data: Stream<D>
{
    logDataStreamLabel<D>[engine=engine](level = |error())

    Self.label -> logDataStreamLabel.label
    Self.data --> logDataStreamLabel.display
}

/**
Log a single trace-level message with a streamed label.

Both `label` and `message` are received as blocks, allowing the label to vary at runtime.
*/
treatment logTraceLabel()
  model engine: Engine()
  input label: Block<string>
  input message: Block<string>
{
    logBlockLabel[engine=engine](level = |trace())

    Self.label ---> logBlockLabel.label
    Self.message -> logBlockLabel.message
}

/**
Log a stream of trace-level messages with a streamed label.

`label` is received as a block; each string in `messages` is logged at trace level under that label.
*/
treatment logTracesLabel()
  model engine: Engine()
  input label: Block<string>
  input messages: Stream<string>
{
    logStreamLabel[engine=engine](level = |trace())

    Self.label ----> logStreamLabel.label
    Self.messages -> logStreamLabel.messages
}

/**
Log a single displayable value at trace level with a streamed label.

Both `label` and `data` are received as blocks; `data` is converted to its display form before logging.
*/
treatment logDataTraceLabel<D: Display>()
  model engine: Engine()
  input label: Block<string>
  input data: Block<D>
{
    logDataBlockLabel<D>[engine=engine](level = |trace())

    Self.label -> logDataBlockLabel.label
    Self.data --> logDataBlockLabel.display
}

/**
Log a stream of displayable values at trace level with a streamed label.

`label` is received as a block; each item in `data` is converted to its display form and logged at trace level.
*/
treatment logDataTracesLabel<D: Display>()
  model engine: Engine()
  input label: Block<string>
  input data: Stream<D>
{
    logDataStreamLabel<D>[engine=engine](level = |trace())

    Self.label -> logDataStreamLabel.label
    Self.data --> logDataStreamLabel.display
}

/**
Log a single info-level message with a streamed label.

Both `label` and `message` are received as blocks, allowing the label to vary at runtime.
*/
treatment logInfoLabel()
  model engine: Engine()
  input label: Block<string>
  input message: Block<string>
{
    logBlockLabel[engine=engine](level = |info())

    Self.label ---> logBlockLabel.label
    Self.message -> logBlockLabel.message
}

/**
Log a stream of info-level messages with a streamed label.

`label` is received as a block; each string in `messages` is logged at info level under that label.
*/
treatment logInfosLabel()
  model engine: Engine()
  input label: Block<string>
  input messages: Stream<string>
{
    logStreamLabel[engine=engine](level = |info())

    Self.label ----> logStreamLabel.label
    Self.messages -> logStreamLabel.messages
}

/**
Log a single displayable value at info level with a streamed label.

Both `label` and `data` are received as blocks; `data` is converted to its display form before logging.
*/
treatment logDataInfoLabel<D: Display>()
  model engine: Engine()
  input label: Block<string>
  input data: Block<D>
{
    logDataBlockLabel<D>[engine=engine](level = |info())

    Self.label -> logDataBlockLabel.label
    Self.data --> logDataBlockLabel.display
}

/**
Log a stream of displayable values at info level with a streamed label.

`label` is received as a block; each item in `data` is converted to its display form and logged at info level.
*/
treatment logDataInfosLabel<D: Display>()
  model engine: Engine()
  input label: Block<string>
  input data: Stream<D>
{
    logDataStreamLabel<D>[engine=engine](level = |info())

    Self.label -> logDataStreamLabel.label
    Self.data --> logDataStreamLabel.display
}

/**
Log a single warning-level message with a streamed label.

Both `label` and `message` are received as blocks, allowing the label to vary at runtime.
*/
treatment logWarningLabel()
  model engine: Engine()
  input label: Block<string>
  input message: Block<string>
{
    logBlockLabel[engine=engine](level = |warning())

    Self.label ---> logBlockLabel.label
    Self.message -> logBlockLabel.message
}

/**
Log a stream of warning-level messages with a streamed label.

`label` is received as a block; each string in `messages` is logged at warning level under that label.
*/
treatment logWarningsLabel()
  model engine: Engine()
  input label: Block<string>
  input messages: Stream<string>
{
    logStreamLabel[engine=engine](level = |warning())

    Self.label ----> logStreamLabel.label
    Self.messages -> logStreamLabel.messages
}

/**
Log a single displayable value at warning level with a streamed label.

Both `label` and `data` are received as blocks; `data` is converted to its display form before logging.
*/
treatment logDataWarningLabel<D: Display>()
  model engine: Engine()
  input label: Block<string>
  input data: Block<D>
{
    logDataBlockLabel<D>[engine=engine](level = |warning())

    Self.label -> logDataBlockLabel.label
    Self.data --> logDataBlockLabel.display
}

/**
Log a stream of displayable values at warning level with a streamed label.

`label` is received as a block; each item in `data` is converted to its display form and logged at warning level.
*/
treatment logDataWarningsLabel<D: Display>()
  model engine: Engine()
  input label: Block<string>
  input data: Stream<D>
{
    logDataStreamLabel<D>[engine=engine](level = |warning())

    Self.label -> logDataStreamLabel.label
    Self.data --> logDataStreamLabel.display
}