@@ -76,7 +76,7 @@ class Journal
76
76
77
77
std::unique_ptr<StructuredLogAttributes> m_attributes;
78
78
79
- static StructuredJournalImpl* m_structuredJournalImpl;
79
+ static std::unique_ptr< StructuredJournalImpl> m_structuredJournalImpl;
80
80
81
81
// Invariant: m_sink always points to a valid Sink
82
82
Sink* m_sink = nullptr ;
@@ -85,9 +85,9 @@ class Journal
85
85
// --------------------------------------------------------------------------
86
86
87
87
static void
88
- enableStructuredJournal (StructuredJournalImpl* impl)
88
+ enableStructuredJournal (std::unique_ptr< StructuredJournalImpl> impl)
89
89
{
90
- m_structuredJournalImpl = impl;
90
+ m_structuredJournalImpl = std::move ( impl) ;
91
91
}
92
92
93
93
static void
@@ -99,7 +99,7 @@ class Journal
99
99
static bool
100
100
isStructuredJournalEnabled ()
101
101
{
102
- return m_structuredJournalImpl;
102
+ return m_structuredJournalImpl != nullptr ;
103
103
}
104
104
105
105
class StructuredJournalImpl
@@ -382,19 +382,13 @@ class Journal
382
382
: m_sink(other.m_sink)
383
383
{
384
384
if (attributes)
385
- {
386
385
m_attributes = std::move (attributes);
387
- }
388
386
if (other.m_attributes )
389
387
{
390
388
if (m_attributes)
391
- {
392
389
m_attributes->combine (other.m_attributes );
393
- }
394
390
else
395
- {
396
391
m_attributes = other.m_attributes ->clone ();
397
- }
398
392
}
399
393
}
400
394
@@ -404,19 +398,13 @@ class Journal
404
398
: m_sink(other.m_sink)
405
399
{
406
400
if (attributes)
407
- {
408
401
m_attributes = std::move (attributes);
409
- }
410
402
if (other.m_attributes )
411
403
{
412
404
if (m_attributes)
413
- {
414
405
m_attributes->combine (std::move (other.m_attributes ));
415
- }
416
406
else
417
- {
418
407
m_attributes = std::move (other.m_attributes );
419
- }
420
408
}
421
409
}
422
410
@@ -439,9 +427,7 @@ class Journal
439
427
{
440
428
m_sink = other.m_sink ;
441
429
if (other.m_attributes )
442
- {
443
430
m_attributes = other.m_attributes ->clone ();
444
- }
445
431
return *this ;
446
432
}
447
433
@@ -450,9 +436,7 @@ class Journal
450
436
{
451
437
m_sink = other.m_sink ;
452
438
if (other.m_attributes )
453
- {
454
439
m_attributes = std::move (other.m_attributes );
455
- }
456
440
return *this ;
457
441
}
458
442
@@ -487,9 +471,7 @@ class Journal
487
471
trace (std::source_location location = std::source_location::current()) const
488
472
{
489
473
if (m_structuredJournalImpl)
490
- {
491
474
m_structuredJournalImpl->initMessageContext (location);
492
- }
493
475
return {
494
476
m_attributes ? m_attributes->clone () : nullptr ,
495
477
*m_sink,
@@ -500,9 +482,7 @@ class Journal
500
482
debug (std::source_location location = std::source_location::current()) const
501
483
{
502
484
if (m_structuredJournalImpl)
503
- {
504
485
m_structuredJournalImpl->initMessageContext (location);
505
- }
506
486
return {
507
487
m_attributes ? m_attributes->clone () : nullptr ,
508
488
*m_sink,
@@ -513,9 +493,7 @@ class Journal
513
493
info (std::source_location location = std::source_location::current()) const
514
494
{
515
495
if (m_structuredJournalImpl)
516
- {
517
496
m_structuredJournalImpl->initMessageContext (location);
518
- }
519
497
return {
520
498
m_attributes ? m_attributes->clone () : nullptr ,
521
499
*m_sink,
@@ -526,9 +504,7 @@ class Journal
526
504
warn (std::source_location location = std::source_location::current()) const
527
505
{
528
506
if (m_structuredJournalImpl)
529
- {
530
507
m_structuredJournalImpl->initMessageContext (location);
531
- }
532
508
return {
533
509
m_attributes ? m_attributes->clone () : nullptr ,
534
510
*m_sink,
@@ -539,9 +515,7 @@ class Journal
539
515
error (std::source_location location = std::source_location::current()) const
540
516
{
541
517
if (m_structuredJournalImpl)
542
- {
543
518
m_structuredJournalImpl->initMessageContext (location);
544
- }
545
519
return {
546
520
m_attributes ? m_attributes->clone () : nullptr ,
547
521
*m_sink,
@@ -552,9 +526,7 @@ class Journal
552
526
fatal (std::source_location location = std::source_location::current()) const
553
527
{
554
528
if (m_structuredJournalImpl)
555
- {
556
529
m_structuredJournalImpl->initMessageContext (location);
557
- }
558
530
return {
559
531
m_attributes ? m_attributes->clone () : nullptr ,
560
532
*m_sink,
0 commit comments