Skip to content

Commit f9557b6

Browse files
committed
docs: Log design
Basic design for Log component.
1 parent 2475433 commit f9557b6

21 files changed

+549
-73
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
@startuml log_interface
2+
3+
package log <<component>> {
4+
+enum Level <<enum>> {
5+
Fatal
6+
Error
7+
Warn
8+
Info
9+
Debug
10+
Trace
11+
}
12+
13+
+enum LevelFilter <<enum>> {
14+
Off
15+
Fatal
16+
Error
17+
Warn
18+
Info
19+
Debug
20+
Trace
21+
}
22+
23+
class mw_log <<module>> {
24+
+set_logger(logger: &'static dyn Log) : Result<(), SetLoggerError>
25+
+set_max_level(level: LevelFilter) : ()
26+
+max_level() : LevelFilter
27+
+logger() : &'static dyn Log
28+
29+
+log!(target: &str, level: Level, ...) : ()
30+
+log_enabled!(target: &str, level: Level) : bool
31+
+fatal!(...) : ()
32+
+error!(...) : ()
33+
+warn!(...) : ()
34+
+info!(...) : ()
35+
+debug!(...) : ()
36+
+trace!(...) : ()
37+
}
38+
39+
class mw_log_macro <<module>> {
40+
+mw_log_format_args!(format_string: &str, args...) : Arguments<'_>
41+
+mw_log_format_args_nl!(format_string: &str, args...) : Arguments<'_>
42+
}
43+
44+
package "mw_log_fmt" {
45+
+interface ScoreDebug <<trait>> {
46+
+fmt(&self, f: &mut dyn ScoreWrite, spec: &FormatSpec) : Result
47+
}
48+
49+
+interface ScoreDisplay <<trait>> {
50+
+fmt(&self, f: &mut dyn ScoreWrite, spec: &FormatSpec) : Result
51+
}
52+
53+
class mw_log_fmt <<module>> {
54+
+write(output: &mut dyn ScoreWrite, args: Arguments<'_>) : Result
55+
56+
+score_write!(format_string: &str, args...) : Result
57+
+score_writeln!(format_string: &str, args...) : Result
58+
}
59+
}
60+
61+
mw_log -- Level
62+
mw_log -- LevelFilter
63+
mw_log -- mw_log_macro
64+
mw_log -- mw_log_fmt
65+
}
66+
67+
68+
69+
@enduml
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@startuml log_with_global_logger
2+
3+
participant "User" as actor
4+
participant "<<component>> log" as frontend
5+
participant "<<component>> mw_log_subscriber" as backend
6+
participant "no-op logger" as nop_logger
7+
8+
actor -> frontend : Log message
9+
10+
frontend -> frontend : Get global logger instance
11+
12+
alt registered
13+
frontend -> backend : Log message
14+
backend --> frontend
15+
else not-registered
16+
frontend -> nop_logger : No-op operation
17+
nop_logger --> frontend
18+
end
19+
20+
frontend --> actor
21+
22+
@enduml
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@startuml log_with_global_logger
2+
3+
participant "User" as actor
4+
participant "<<component>> log" as frontend
5+
participant "<<component>> mw_log_subscriber" as backend
6+
7+
actor -> backend : Create concrete logger instance
8+
backend --> actor : Logger instance
9+
10+
actor -> frontend : Log message with logger instance
11+
12+
frontend -> backend : Log message
13+
backend --> frontend
14+
15+
frontend --> actor
16+
17+
@enduml
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@startuml register_global_logger
2+
3+
participant "User" as actor
4+
participant "<<component>> mw_log_subscriber" as backend
5+
participant "<<component>> log" as frontend
6+
7+
actor -> backend : Create concrete logger instance
8+
backend --> actor : Logger instance
9+
10+
actor -> frontend : Set logger
11+
alt set-success
12+
frontend --> actor : Ok
13+
else set-failed
14+
frontend --> actor : Error code
15+
end
16+
17+
@enduml
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@startuml log_static_view
2+
3+
package "log" <<component>> {
4+
component "mw_log" <<interface>>
5+
6+
component "mw_log_fmt"
7+
8+
component "mw_log_macro"
9+
10+
mw_log ..> mw_log_fmt : use
11+
mw_log ..> mw_log_macro : use
12+
}
13+
14+
component "mw_log_subscriber" <<component>>
15+
note bottom: "Backend implementation."
16+
17+
mw_log --> "mw_log_subscriber" : implements
18+
19+
20+
@enduml

docs/module/log/architecture/index.rst

Lines changed: 51 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Component Architecture
2020
.. document:: Log Architecture
2121
:id: doc__log_architecture
2222
:status: draft
23-
:safety: QM
23+
:safety: ASIL_B
2424
:security: NO
2525
:realizes: wp__component_arch
2626
:tags: log
@@ -35,63 +35,77 @@ Document describes Log component architecture.
3535
Description
3636
-----------
3737

38-
TODO: description
38+
Log component is modelled after `log` library, which is ubiquitous in Rust ecosystem.
39+
This provides familiar APIs and syntax - provided APIs can be replaced at compile time with `log`.
40+
41+
Component provides new formatting functionality (replacement to `core::fmt`) to ensure improved flexibility in formatting on backend side.
42+
E.g., numeric types are formatted by the backend, and not by the core library.
43+
44+
Even though design is similar - existing `log` implementations are not compatible.
3945

4046

4147
Rationale Behind Architecture Decomposition
4248
*******************************************
4349

44-
TODO: decomposition rationale
50+
Architecture is not decomposed.
51+
Log component is a monolithic frontend.
52+
4553

4654
Static Architecture
4755
-------------------
4856

49-
TODO: static architecture
50-
51-
.. .. comp_arc_sta:: Log (Static View)
52-
.. :id: comp_arc_sta__log__static_view
53-
.. :security: YES
54-
.. :safety: QM
55-
.. :status: invalid
56-
.. :implements: logic_arc_int__log__interface_name
57-
.. :fulfils:
58-
.. :includes:
57+
.. comp_arc_sta:: Log (Static View)
58+
:id: comp_arc_sta__log__static_view
59+
:security: NO
60+
:safety: ASIL_B
61+
:status: valid
62+
:implements:
63+
:fulfils:
64+
:includes:
5965

60-
.. .. uml:: _assets/TODO.puml
66+
.. uml:: _assets/static_view.puml
6167

6268

6369
Dynamic Architecture
6470
--------------------
6571

66-
TODO: dynamic architecture
67-
68-
.. .. comp_arc_dyn:: Dynamic View
69-
.. :id: comp_arc_dyn__log__dynamic_view
70-
.. :security: YES
71-
.. :safety: QM
72-
.. :status: invalid
73-
.. :fulfils: comp_req__log__some_title
72+
.. comp_arc_dyn:: Register global logger
73+
:id: comp_arc_dyn__log__register_global_logger
74+
:security: NO
75+
:safety: ASIL_B
76+
:status: valid
77+
:fulfils:
7478

75-
.. .. uml:: _assets/TODO.puml
79+
.. uml:: _assets/register_global_logger.puml
7680

81+
.. comp_arc_dyn:: Log with global logger instance
82+
:id: comp_arc_dyn__log__log_with_global_logger
83+
:security: NO
84+
:safety: ASIL_B
85+
:status: valid
86+
:fulfils:
7787

78-
Interfaces
79-
----------
88+
.. uml:: _assets/log_with_global_logger.puml
8089

81-
TODO: put log interfaces.
90+
.. comp_arc_dyn:: Log with local logger instance
91+
:id: comp_arc_dyn__log__log_with_local_logger
92+
:security: NO
93+
:safety: ASIL_B
94+
:status: valid
95+
:fulfils:
8296

83-
.. .. code-block:: rst
97+
.. uml:: _assets/log_with_local_logger.puml
8498

85-
.. .. real_arc_int:: mw_log
86-
.. :id: real_arc_int__log__interface
87-
.. :security: NO
88-
.. :safety: QM
89-
.. :fulfils:
90-
.. :language: rust
9199

92-
.. .. uml:: _assets/TODO.puml
100+
Interfaces
101+
----------
93102

94-
Lower Level Components
95-
----------------------
103+
.. real_arc_int:: Log interface
104+
:id: real_arc_int__log__interface
105+
:security: NO
106+
:safety: ASIL_B
107+
:status: valid
108+
:fulfils:
109+
:language: rust
96110

97-
TODO: remove section if unused
111+
.. uml:: _assets/interface.puml

docs/module/log/component_classification.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Component Classification
1919
.. document:: Log Component Classification
2020
:id: doc__log_comp_class
2121
:status: draft
22-
:safety: QM
22+
:safety: ASIL_B
2323
:security: NO
2424
:realizes: wp__sw_component_class
2525
:tags: log

0 commit comments

Comments
 (0)