journald-native 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/ext/journald_native/journald_native.cpp +5 -26
- data/lib/journald/native/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7074ca755c39b71b382f63b7befe21e0dc7e18ec
|
4
|
+
data.tar.gz: 585840efef3b5ee2b50f97e830ecf21df0ec811b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e19cdf3224ca356c47319c5dd6897cc364a8f4d87a1f9c7d9319a31be19be2b4298cbc1b869024e8f0846f48115947dc296afb9d809de368bc16ae18434cdb2a
|
7
|
+
data.tar.gz: 214828671762b128ae1875fffce35e8a3db25217db47e6bca8d4a127750c3ad1ca55d9c8999c623829dce3a8b998ffe70d2fe62395b3dedf75b3479d3487532a
|
data/README.md
CHANGED
@@ -44,9 +44,9 @@ Journald::Native.print Journald::LOG_WARNING, "message"
|
|
44
44
|
Journald::Native.perror "message"
|
45
45
|
```
|
46
46
|
|
47
|
-
It is not recommended to use ```print``` and ```perror``` as you may
|
48
|
-
C zero-terminated string format
|
49
|
-
|
47
|
+
It is not recommended to use ```print``` and ```perror``` as you may get exception if your string contains
|
48
|
+
```'\0'``` byte due to C zero-terminated string format. On the contrary ```send``` uses binary buffers and
|
49
|
+
does not have this shortcoming.
|
50
50
|
|
51
51
|
### License
|
52
52
|
|
@@ -17,34 +17,13 @@ inline auto r(Func f, Args... args) -> decltype(f(args...))
|
|
17
17
|
return ruby_exception_wrapper::ruby_raisable_call(f, args...);
|
18
18
|
}
|
19
19
|
|
20
|
-
// Remove zeros from the string
|
21
|
-
std::string create_safe_string(VALUE v_string)
|
22
|
-
{
|
23
|
-
/* convert to string */
|
24
|
-
r(rb_string_value, &v_string);
|
25
|
-
|
26
|
-
char* str = (char *)RSTRING_PTR(v_string);
|
27
|
-
size_t len = (size_t)RSTRING_LEN(v_string);
|
28
|
-
|
29
|
-
std::string safe_str;
|
30
|
-
safe_str.reserve(len);
|
31
|
-
|
32
|
-
for (size_t i = 0; i < len; i++) {
|
33
|
-
if (str[i]) {
|
34
|
-
safe_str += str[i];
|
35
|
-
}
|
36
|
-
}
|
37
|
-
|
38
|
-
return safe_str;
|
39
|
-
}
|
40
|
-
|
41
20
|
/* methods */
|
42
21
|
inline VALUE native_print(VALUE v_self, VALUE v_priority, VALUE v_message)
|
43
22
|
{
|
44
|
-
int
|
45
|
-
|
23
|
+
int priority = NUM2INT(v_priority);
|
24
|
+
std::string message = r(rb_string_value_cstr, &v_message);
|
46
25
|
|
47
|
-
int
|
26
|
+
int result = sd_journal_print(priority, "%s", message.c_str());
|
48
27
|
|
49
28
|
return INT2NUM(result);
|
50
29
|
}
|
@@ -67,9 +46,9 @@ inline VALUE native_send(int argc, VALUE* argv, VALUE v_self)
|
|
67
46
|
|
68
47
|
inline VALUE native_perror(VALUE v_self, VALUE v_message)
|
69
48
|
{
|
70
|
-
|
49
|
+
std::string message = r(rb_string_value_cstr, &v_message);
|
71
50
|
|
72
|
-
int
|
51
|
+
int result = sd_journal_perror(message.c_str());
|
73
52
|
|
74
53
|
return INT2NUM(result);
|
75
54
|
}
|