Skip to content

Commit 46f0a20

Browse files
committed
reformating
1 parent 499f334 commit 46f0a20

File tree

1 file changed

+51
-63
lines changed

1 file changed

+51
-63
lines changed

doc/scriptingAPI.md

Lines changed: 51 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,82 @@
1+
12
# Scripting API
23

3-
This document describes the interface to be used to inject messages into the InfoLogger logging system
4-
from languages other than C or C++.
4+
This document describes the interface to be used to inject messages into the InfoLogger logging system from languages other than C or C++.
55

66
Languages currently supported are: Tcl, Python, Go, Javascript (node.js/v8).
77

8-
A subset of the InfoLogger C++ API (covering most use-cases) is exported using SWIG-generated modules.
9-
This avoids the tedious work of manually writing native bindings calling the C++ library for each language
10-
(although this is still possible for the brave). InfoLogger provides them ready to use!
8+
A subset of the InfoLogger C++ API (covering most use-cases) is exported using SWIG-generated modules. This avoids the tedious work of manually writing native bindings calling the C++ library for each language (although this is still possible for the brave). InfoLogger provides them ready to use!
119

12-
This documentation includes a reference of the exported functions, and language-specific example code
13-
calling the infoLogger module.
10+
This documentation includes a reference of the exported functions, and language-specific example code calling the infoLogger module.
1411

15-
As the C++ interface uses some complex types which can not be transparently converted to all languages,
16-
we defined this simplified API with string-only parameters.
17-
Although some overhead is added by the generalized used of strings to access the logging message structure fields
18-
(compared to the native C++ API), the performance loss is not significant for most situations. A typical machine
19-
can still log over 100000 messages per second from a script.
12+
As the C++ interface uses some complex types which can not be transparently converted to all languages, we defined this simplified API with string-only parameters. Although some overhead is added by the generalized used of strings to access the logging message structure fields (compared to the native C++ API), the performance loss is not significant for most situations. A typical machine can still log over 100000 messages per second from a script.
2013

2114

2215

2316
## Classes reference
2417

2518
Default constructor and destructor are not shown here.
2619

27-
* class InfoLogger
28-
The main class, to create a handle to the logging system. It provides the methods to inject log messages.
29-
Methods:
30-
* logInfo(string message)
20+
* `class InfoLogger`
21+
22+
The main class, to create a handle to the logging system. It provides the methods to inject log messages:
23+
* `logInfo(string message)`
3124
Sends a message with severity Info.
32-
* logError(string message)
25+
* `logError(string message)`
3326
Sends a message with severity Error.
34-
* logWarning(string message)
27+
* `logWarning(string message)`
3528
Sends a message with severity Warning.
36-
* logFatal(string message)
29+
* `logFatal(string message)`
3730
Sends a message with severity Fatal.
38-
* logDebug(string message)
31+
* `logDebug(string message)`
3932
Sends a message with severity Debug.
40-
* log(message)
33+
* `log(message)`
4134
Sends a message with default severity and metadata.
42-
* log(InfoLoggerMetadata metadata, string message)
35+
* `log(InfoLoggerMetadata metadata, string message)`
4336
Send a message with specific metadata (instead of the default, if one defined).
44-
* setDefaultMetadata(InfoLoggerMetadata metadata);
37+
* `setDefaultMetadata(InfoLoggerMetadata metadata)`
4538
Define some metadata to be used by default for all messages.
46-
* unsetDefaultMetadata();
39+
* `unsetDefaultMetadata()`
4740
Reset the default metadata.
4841

49-
* class InfoLoggerMetadata
50-
It is used to specify extra fields associated to a log message.
51-
An object of this type can be optionnaly provided to the logging function to set some specific message fields.
52-
Methods:
53-
* setField(string key, string value)
54-
Set one of the field to a specific value. An empty value reset this field to the default.
55-
List of valid fields include: Severity, Level, ErrorCode, SourceFile, SourceLine, Facility, Role, System, Detector, Partition, Run
56-
* InfoLoggerMetadata(InfoLoggerMetadata)
57-
Copy-constructor, to copy an existing InfoLoggerMetadata object to a new one.
58-
59-
6042

43+
* `class InfoLoggerMetadata`
6144

45+
It is used to specify extra fields associated to a log message. An object of this type can be optionnaly provided to the logging function to set some specific message fields.
46+
* `setField(string key, string value)`
47+
Set one of the field to a specific value. An empty value reset this field to the default. List of valid fields include: *Severity, Level, ErrorCode, SourceFile, SourceLine, Facility, Role, System, Detector, Partition, Run*
48+
* `InfoLoggerMetadata(InfoLoggerMetadata)`
49+
Copy-constructor, to copy an existing InfoLoggerMetadata object to a new one.
6250

6351

6452
## Example usage
6553

66-
Example usage is shown below. Library files listed there are available from the infoLogger library installation directory.
67-
68-
* Tcl
69-
** Library files: infoLoggerForTcl.so
70-
** Code example: (interactive interpreter from the command line)
71-
```
72-
tclsh
73-
load infoLoggerForTcl.so
74-
set logHandle [InfoLogger]
75-
$logHandle logInfo "This is a test"
76-
$logHandle logError "Something went wrong"
77-
```
78-
* Python
79-
** Library files: _infoLoggerForPython.so and infoLoggerForPython.py
80-
** Code example: (interactive interpreter from the command line)
81-
```
82-
python
83-
import infoLoggerForPython
84-
logHandle=infoLoggerForPython.InfoLogger()
85-
logHandle.logInfo("This is a test")
86-
logHandle.logError("Something went wrong")
87-
```
88-
* Go
89-
** Library files: infoLoggerForGo.a and infoLoggerForGo.go (to be copied to ${GOPATH}/src/infoLoggerForGo)
90-
** Build: CGO_LDFLAGS="${GOPATH}/src/infoLoggerForGo/infoLoggerForGo.a -lstdc++" go build
91-
** Code example:
54+
Example usage is shown below. Library files listed there are available from the infoLogger library installation directory.
55+
56+
* **Tcl**
57+
* Library files: `infoLoggerForTcl.so`
58+
* Code example: (interactive interpreter from the command line)
59+
```
60+
tclsh
61+
load infoLoggerForTcl.so
62+
set logHandle [InfoLogger]
63+
$logHandle logInfo "This is a test"
64+
$logHandle logError "Something went wrong"
65+
```
66+
* **Python**
67+
* Library files: `_infoLoggerForPython.so` and `infoLoggerForPython.py`
68+
* Code example: (interactive interpreter from the command line)
69+
```
70+
python
71+
import infoLoggerForPython
72+
logHandle=infoLoggerForPython.InfoLogger()
73+
logHandle.logInfo("This is a test")
74+
logHandle.logError("Something went wrong")
75+
```
76+
* **Go**
77+
* Library files: `infoLoggerForGo.a` and `infoLoggerForGo.go`, to be copied to your `${GOPATH}/src/infoLoggerForGo`
78+
* Build: `CGO_LDFLAGS="${GOPATH}/src/infoLoggerForGo/infoLoggerForGo.a -lstdc++" go build`
79+
* Code example:
9280
```
9381
package main
9482
import "infoLoggerForGo"
@@ -99,5 +87,5 @@ Default constructor and destructor are not shown here.
9987
}
10088
```
10189
102-
103-
NB: don't forget to delete the objects if necessary!
90+
## Tips
91+
Don't forget to delete the objects if necessary!

0 commit comments

Comments
 (0)