Skip to content

Commit 6f12a82

Browse files
authored
feature/cli-runner - Update logging info in C++ and Python SDK docs. (#120)
* Update logging info in C++ and Python SDK docs.
1 parent 8d6850b commit 6f12a82

14 files changed

Lines changed: 291 additions & 225 deletions

File tree

docs/docs/CPP-Batch-Component-API.md

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ string GetRunDirectory()
140140
string run_dir = GetRunDirectory();
141141
string plugin_path = run_dir + "/SampleComponent";
142142
string config_path = plugin_path + "/config";
143-
string logconfig_file = config_path + "/Log4cxxConfig.xml";
144143
```
145144

146145
### Init()
@@ -1051,7 +1050,7 @@ It is recommended that C++ components are organized according to the following d
10511050
10521051
```
10531052
componentName
1054-
├── config - Logging and other component-specific configuration
1053+
├── config - Optional component-specific configuration files
10551054
├── descriptor
10561055
│ └── descriptor.json
10571056
└── lib
@@ -1062,41 +1061,25 @@ Once built, components should be packaged into a .tar.gz containing the contents
10621061
10631062
10641063
## Logging
1064+
It is recommended to use [Apache log4cxx](https://logging.apache.org/log4cxx/index.html) for
1065+
OpenMPF Component logging. Components using log4cxx should not configure logging themselves.
1066+
The component executor will configure log4cxx globally. Components should call
1067+
`log4cxx::Logger::getLogger("<componentName>")` to a get a reference to the logger. If you
1068+
are using a different logging framework, you should make sure its behavior is similar to how
1069+
the component executor configures log4cxx as described below.
10651070
1066-
It is recommended to use [Apache log4cxx](https://logging.apache.org/log4cxx/index.html) for OpenMPF Component logging.
1071+
The following log LEVELs are supported: `FATAL, ERROR, WARN, INFO, DEBUG, TRACE`.
1072+
The `LOG_LEVEL` environment variable can be set to one of the log levels to change the logging
1073+
verbosity. When `LOG_LEVEL` is absent, `INFO` is used.
10671074
1068-
Note that multiple instances of the same component can log to the same file. Also, logging content can span multiple lines.
1075+
Note that multiple instances of the same component can log to the same file.
1076+
Also, logging content can span multiple lines.
10691077
1070-
Log files should be output to:
1071-
`${MPF_LOG_PATH}/${THIS_MPF_NODE}/log/<componentName>.log`
1078+
The logger will write to both standard error and
1079+
`${MPF_LOG_PATH}/${THIS_MPF_NODE}/log/<componentName>.log`.
10721080
1073-
Each log statement must take the form:
1081+
Each log statement will take the form:
10741082
`DATE TIME LEVEL CONTENT`
10751083
1076-
The following log LEVELs are supported:
1077-
`FATAL, ERROR, WARN, INFO, DEBUG, TRACE`.
1078-
10791084
For example:
10801085
`2016-02-09 13:42:42,341 INFO - Starting sample-component: [ OK ]`
1081-
1082-
The following configuration can be used to match the format of other OpenMPF logs:
1083-
1084-
```xml
1085-
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
1086-
1087-
<!-- Output the log message to log file-->
1088-
<appender name="SAMPLECOMPONENT-FILE" class="org.apache.log4j.DailyRollingFileAppender">
1089-
<param name="file" value="${MPF_LOG_PATH}/${THIS_MPF_NODE}/log/<componentName>.log" />
1090-
<param name="DatePattern" value="'.'yyyy-MM-dd" />
1091-
<layout class="org.apache.log4j.PatternLayout">
1092-
<param name="ConversionPattern" value="%d %p [%t] %c{36}:%L - %m%n" />
1093-
</layout>
1094-
</appender>
1095-
1096-
<logger name= "SampleComponent" additivity="false">
1097-
<level value="INFO"/>
1098-
<appender-ref ref="SAMPLECOMPONENT-FILE"/>
1099-
</logger>
1100-
1101-
</log4j:configuration>
1102-
```

docs/docs/CPP-Streaming-Component-API.md

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ MPFStreamingDetectionComponent(const MPFStreamingVideoJob &job)
137137
```c++
138138
SampleComponent::SampleComponent(const MPFStreamingVideoJob &job)
139139
: MPFStreamingDetectionComponent(job)
140-
, hw_logger_(GetLogger(job.run_directory))
140+
, hw_logger_(log4cxx::Logger::getLogger("SampleComponent"))
141141
, job_name_(job.job_name) {
142142
143143
LOG4CXX_INFO(hw_logger_, "[" << job_name_ << "] Initialized SampleComponent component.")
@@ -430,7 +430,7 @@ It is recommended that C++ components are organized according to the following d
430430
431431
```
432432
componentName
433-
├── config - Logging and other component-specific configuration
433+
├── config - Component-specific configuration files
434434
├── descriptor
435435
│ └── descriptor.json
436436
└── lib
@@ -441,41 +441,25 @@ Once built, components should be packaged into a .tar.gz containing the contents
441441
442442
443443
## Logging
444+
It is recommended to use [Apache log4cxx](https://logging.apache.org/log4cxx/index.html) for
445+
OpenMPF Component logging. Components using log4cxx should not configure logging themselves.
446+
The component executor will configure log4cxx globally. Components should call
447+
`log4cxx::Logger::getLogger("<componentName>")` to a get a reference to the logger. If you
448+
are using a different logging framework, you should make sure its behavior is similar to how
449+
the component executor configures log4cxx as described below.
444450
445-
It is recommended to use [Apache log4cxx](https://logging.apache.org/log4cxx/index.html) for OpenMPF Component logging.
451+
The following log LEVELs are supported: `FATAL, ERROR, WARN, INFO, DEBUG, TRACE`.
452+
The `LOG_LEVEL` environment variable can be set to one of the log levels to change the logging
453+
verbosity. When `LOG_LEVEL` is absent, `INFO` is used.
446454
447-
Note that multiple instances of the same component can log to the same file. Also, logging content can span multiple lines.
455+
Note that multiple instances of the same component can log to the same file.
456+
Also, logging content can span multiple lines.
448457
449-
Log files should be output to:
450-
`${MPF_LOG_PATH}/${THIS_MPF_NODE}/log/<componentName>.log`
458+
The logger will write to both standard error and
459+
`${MPF_LOG_PATH}/${THIS_MPF_NODE}/log/<componentName>.log`.
451460
452-
Each log statement must take the form:
461+
Each log statement will take the form:
453462
`DATE TIME LEVEL CONTENT`
454463
455-
The following log LEVELs are supported:
456-
`FATAL, ERROR, WARN, INFO, DEBUG, TRACE`.
457-
458464
For example:
459465
`2016-02-09 13:42:42,341 INFO - Starting sample-component: [ OK ]`
460-
461-
The following configuration can be used to match the format of other OpenMPF logs:
462-
463-
```xml
464-
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
465-
466-
<!-- Output the log message to log file-->
467-
<appender name="SAMPLECOMPONENT-FILE" class="org.apache.log4j.DailyRollingFileAppender">
468-
<param name="file" value="${MPF_LOG_PATH}/${THIS_MPF_NODE}/log/<componentName>.log" />
469-
<param name="DatePattern" value="'.'yyyy-MM-dd" />
470-
<layout class="org.apache.log4j.PatternLayout">
471-
<param name="ConversionPattern" value="%d %p [%t] %c{36}:%L - %m%n" />
472-
</layout>
473-
</appender>
474-
475-
<logger name= "SampleComponent" additivity="false">
476-
<level value="INFO"/>
477-
<appender-ref ref="SAMPLECOMPONENT-FILE"/>
478-
</logger>
479-
480-
</log4j:configuration>
481-
```

docs/docs/Python-Batch-Component-API.md

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,14 @@ Below is an example of the structure of a simple component. This component exten
221221
[`mpf_component_util.VideoCapture`](#mpf_component_utilvideocapture). You would replace the call to
222222
`run_detection_algorithm_on_frame` with your component-specific logic.
223223
```python
224+
import logging
225+
224226
import mpf_component_api as mpf
225227
import mpf_component_util as mpf_util
226228

227-
logger = mpf.configure_logging('my-component.log', __name__ == '__main__')
229+
logger = logging.getLogger('MyComponent')
228230

229-
class MyComponent(mpf_util.VideoCaptureMixin, object):
231+
class MyComponent(mpf_util.VideoCaptureMixin):
230232
detection_type = 'FACE'
231233

232234
@staticmethod
@@ -314,11 +316,11 @@ Below is an example of the structure of a simple component that does not use
314316
[`mpf_component_util.VideoCaptureMixin`](#mpf_component_utilvideocapturemixin). You would replace the call to
315317
`run_detection_algorithm` with your component-specific logic.
316318
```python
317-
import mpf_component_api as mpf
319+
import logging
318320

319-
logger = mpf.configure_logging('my-component.log', __name__ == '__main__')
321+
logger = logging.getLogger('MyComponent')
320322

321-
class MyComponent(object):
323+
class MyComponent:
322324
detection_type = 'FACE'
323325

324326
@staticmethod
@@ -368,22 +370,22 @@ For example:
368370

369371
instance method:
370372
```python
371-
class MyComponent(object):
373+
class MyComponent:
372374
def get_detections_from_image(self, image_job):
373375
return [mpf_component_api.ImageLocation(...), ...]
374376
```
375377

376378
static method:
377379
```python
378-
class MyComponent(object):
380+
class MyComponent:
379381
@staticmethod
380382
def get_detections_from_image(image_job):
381383
return [mpf_component_api.ImageLocation(...), ...]
382384
```
383385

384386
class method:
385387
```python
386-
class MyComponent(object):
388+
class MyComponent:
387389
@classmethod
388390
def get_detections_from_image(cls, image_job):
389391
return [mpf_component_api.ImageLocation(...), ...]
@@ -399,7 +401,7 @@ but any iterable can be used.
399401
Examples include: `FACE`, `MOTION`, `PERSON`, `SPEECH`, `CLASS` (for object classification), or `TEXT`.
400402
* Example:
401403
```python
402-
class MyComponent(object):
404+
class MyComponent:
403405
detection_type = 'FACE'
404406

405407
```
@@ -413,7 +415,7 @@ Used to detect objects in an image file.
413415

414416
* Method Definition:
415417
```python
416-
class MyComponent(object):
418+
class MyComponent:
417419
def get_detections_from_image(self, image_job):
418420
return [mpf_component_api.ImageLocation(...), ...]
419421
```
@@ -548,7 +550,7 @@ cannot automatically perform the reverse transform for the developer.
548550

549551
The general pattern for using `mpf_component_util.ImageReader` is as follows:
550552
```python
551-
class MyComponent(object):
553+
class MyComponent:
552554

553555
@staticmethod
554556
def get_detections_from_image(image_job):
@@ -583,7 +585,7 @@ There are some requirements to properly use `mpf_component_util.ImageReaderMixin
583585

584586
The general pattern for using `mpf_component_util.ImageReaderMixin` is as follows:
585587
```python
586-
class MyComponent(mpf_component_util.ImageReaderMixin, object):
588+
class MyComponent(mpf_component_util.ImageReaderMixin):
587589

588590
@staticmethod # Can also be a regular instance method or a class method
589591
def get_detections_from_image_reader(image_job, image_reader):
@@ -612,7 +614,7 @@ request for frames 300-399 of a Video A, while the next request may cover frames
612614

613615
* Method Definition:
614616
```python
615-
class MyComponent(object):
617+
class MyComponent:
616618
def get_detections_from_video(self, video_job):
617619
return [mpf_component_api.VideoTrack(...), ...]
618620
```
@@ -767,7 +769,7 @@ cannot automatically perform the reverse transform for the developer.
767769

768770
The general pattern for using `mpf_component_util.VideoCapture` is as follows:
769771
```python
770-
class MyComponent(object):
772+
class MyComponent:
771773

772774
@staticmethod
773775
def get_detections_from_video(video_job):
@@ -804,7 +806,7 @@ There are some requirements to properly use `mpf_component_util.VideoCaptureMixi
804806

805807
The general pattern for using `mpf_component_util.VideoCaptureMixin` is as follows:
806808
```python
807-
class MyComponent(mpf_component_util.VideoCaptureMixin, object):
809+
class MyComponent(mpf_component_util.VideoCaptureMixin):
808810

809811
@staticmethod # Can also be a regular instance method or a class method
810812
def get_detections_from_video_capture(video_job, video_capture):
@@ -824,7 +826,7 @@ from extending other classes. If a component supports both videos and images, an
824826
[`mpf_component_util.ImageReaderMixin`](#mpf_component_utilimagereadermixin).
825827
For example:
826828
```python
827-
class MyComponent(mpf_component_util.VideoCaptureMixin, mpf_component_util.ImageReaderMixin, object):
829+
class MyComponent(mpf_component_util.VideoCaptureMixin, mpf_component_util.ImageReaderMixin):
828830

829831
@staticmethod
830832
def get_detections_from_video_capture(video_job, video_capture):
@@ -845,7 +847,7 @@ Used to detect objects in an audio file.
845847

846848
* Method Definition:
847849
```python
848-
class MyComponent(object):
850+
class MyComponent:
849851
def get_detections_from_audio(self, audio_job):
850852
return [mpf_component_api.AudioTrack(...), ...]
851853
```
@@ -970,7 +972,7 @@ handled generically.
970972

971973
* Method Definition:
972974
```python
973-
class MyComponent(object):
975+
class MyComponent:
974976
def get_detections_from_generic(self, generic_job):
975977
return [mpf_component_api.GenericTrack(...), ...]
976978
```
@@ -1190,11 +1192,17 @@ OpenMPF components should be stateless in operation and give identical output fo
11901192

11911193

11921194
## Logging
1193-
It recommended that components use the logger returned from:
1194-
<br> `mpf_component_api.configure_logging(log_file_name, debug=False, replace_existing_config=True)`.
1195-
The logger will write log messages to standard out. When `debug` is false, the log messages will also be written to `${MPF_LOG_PATH}/${THIS_MPF_NODE}/log/<log_file_name>.log` Note that multiple instances of the same component
1196-
can log to the same file. Also, logging content can span multiple lines. The following log levels are supported:
1197-
`FATAL, ERROR, WARN, INFO, DEBUG`.
1195+
It recommended that components use Python's built-in
1196+
[`logging` module.](https://docs.python.org/3/library/logging.html) The component should
1197+
`import logging` and call `logging.getLogger('<componentName>')` to get a logger instance.
1198+
The component should not configure logging itself. The component executor will configure the
1199+
`logging` module for the component. The logger will write log messages to standard error and
1200+
`${MPF_LOG_PATH}/${THIS_MPF_NODE}/log/<componentName>.log`. Note that multiple instances of the
1201+
same component can log to the same file. Also, logging content can span multiple lines.
1202+
1203+
The following log levels are supported: `FATAL, ERROR, WARN, INFO, DEBUG`.
1204+
The `LOG_LEVEL` environment variable can be set to one of the log levels to change the logging
1205+
verbosity. When `LOG_LEVEL` is absent, `INFO` is used.
11981206

11991207
The format of the log messages is:
12001208
```

docs/docs/Release-Notes.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,45 @@
11
> **NOTICE:** This software (or technical data) was produced for the U.S. Government under contract, and is subject to the Rights in Data-General Clause 52.227-14, Alt. IV (DEC 2007). Copyright 2021 The MITRE Corporation. All Rights Reserved.
22
3+
# OpenMPF TBD: XXX
4+
5+
<h2>OpenMPF Command Line Runner</h2>
6+
7+
- The Command Line Runner allows users to run jobs with a single component without the
8+
Workflow Manager.
9+
- It outputs results in a JSON structure that is a subset of the regular OpenMPF output.
10+
- It only supports C++ and Python components.
11+
- See the
12+
[README](https://github.com/openmpf/openmpf-docker/blob/master/CLI_RUNNER.md)
13+
for more information.
14+
15+
<h2>C++ Batch Component API</h2>
16+
- Component code should no longer configure Log4CXX. The component executor now handles
17+
configuring Log4CXX. Component code should call `log4cxx::Logger::getLogger("<component-name>")`
18+
to get access to the logger. Calls to `log4cxx::xml::DOMConfigurator::configure(logconfig_file);`
19+
should be removed.
20+
21+
22+
<h2>Python Batch Component API </h2>
23+
- Component code should no longer configure logging. The component executor now handles
24+
configuring logging. Calls to `mpf.configure_logging` should be replaced with
25+
`logging.getLogger('<component-name>')`.
26+
27+
28+
<h2>Docker Component Base Images</h2>
29+
- In order to support running a component through the CLI runner, C++ component developers should
30+
set the `LD_LIBRARY_PATH` environment variable in the final stage of their Dockerfiles. It should
31+
generally be set like: `ENV LD_LIBRARY_PATH $PLUGINS_DIR/<component-name>/lib`.
32+
33+
- Because of the logging changes mentioned above, components no longer need to set the
34+
`COMPONENT_LOG_NAME` environment variable in their Dockerfiles.
35+
36+
- Added the
37+
[`openmpf_python_executor_ssb` base image](https://github.com/openmpf/openmpf-docker/blob/master/components/python/README.md#openmpf_python_executor_ssb).
38+
It can be used instead of `openmpf_python_component_build` and `openmpf_python_executor` to
39+
simplify Dockerfiles for Python components that are pure Python and have no build time
40+
dependencies.
41+
42+
343
# OpenMPF 6.0.1: December 2020
444

545
<h2>Bug Fixes</h2>

docs/docs/User-Guide.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@ Copyright 2021 The MITRE Corporation. All Rights Reserved.
55
66
# General
77

8+
The Open Media Processing Framework (OpenMPF) can be used in three ways:
9+
10+
* Through the OpenMPF Web user interface (UI)
11+
* Through the [REST API endpoints](#rest-api)
12+
* Through the [CLI Runner](https://github.com/openmpf/openmpf-docker/blob/master/CLI_RUNNER.md)
13+
14+
815
## Accessing the Web UI
916

10-
On the server hosting the Open Media Processing Framework (OpenMPF), the Web UI is accessible at http://localhost:8080/workflow-manager. To access it from other machines, substitute the hostname or IP address of the master node server in place of "localhost".
17+
On the server hosting the Open Media Processing Framework, the Web UI is accessible at http://localhost:8080/workflow-manager. To access it from other machines, substitute the hostname or IP address of the master node server in place of "localhost".
1118

12-
The OpenMPF user interface (UI) was designed and tested for use with Chrome and FireFox. It has not been tested with other browsers. Attempting to use an unsupported browser will result in a warning.
19+
The OpenMPF user interface was designed and tested for use with Chrome and FireFox. It has not been tested with other browsers. Attempting to use an unsupported browser will result in a warning.
1320

1421
## Logging In
1522

@@ -190,7 +197,7 @@ The "Processes" tab on this page allows a user to view a table with information
190197

191198
## REST API
192199

193-
This page allows a user to try out the various REST API endpoints provided by the workflow manager. It is intended to serve as a learning tool for technical users who wish to design and build systems that interact with the OpenMPF.
200+
This page allows a user to try out the [various REST API endpoints](REST-API) provided by the workflow manager. It is intended to serve as a learning tool for technical users who wish to design and build systems that interact with the OpenMPF.
194201

195202
After selecting a functional category, such as "meta", "jobs", "statistics", "nodes", "pipelines", or "system-message", each REST endpoint for that category is shown in a list. Selecting one of them will cause it to expand and reveal more information about the request and response structures. If the request takes any parameters then a section will appear that allows the user to manually specify them.
196203

0 commit comments

Comments
 (0)