You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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++.
5
5
6
6
Languages currently supported are: Tcl, Python, Go, Javascript (node.js/v8).
7
7
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!
11
9
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.
14
11
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.
20
13
21
14
22
15
23
16
## Classes reference
24
17
25
18
Default constructor and destructor are not shown here.
26
19
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)`
31
24
Sends a message with severity Info.
32
-
* logError(string message)
25
+
*`logError(string message)`
33
26
Sends a message with severity Error.
34
-
* logWarning(string message)
27
+
*`logWarning(string message)`
35
28
Sends a message with severity Warning.
36
-
* logFatal(string message)
29
+
*`logFatal(string message)`
37
30
Sends a message with severity Fatal.
38
-
* logDebug(string message)
31
+
*`logDebug(string message)`
39
32
Sends a message with severity Debug.
40
-
* log(message)
33
+
*`log(message)`
41
34
Sends a message with default severity and metadata.
Define some metadata to be used by default for all messages.
46
-
* unsetDefaultMetadata();
39
+
*`unsetDefaultMetadata()`
47
40
Reset the default metadata.
48
41
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
-
60
42
43
+
*`class InfoLoggerMetadata`
61
44
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.
62
50
63
51
64
52
## Example usage
65
53
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:
92
80
```
93
81
package main
94
82
import "infoLoggerForGo"
@@ -99,5 +87,5 @@ Default constructor and destructor are not shown here.
99
87
}
100
88
```
101
89
102
-
103
-
NB: don't forget to delete the objects if necessary!
0 commit comments