This repository was archived by the owner on Jun 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathrlogging.c
72 lines (55 loc) · 1.43 KB
/
rlogging.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*------------------------------------------------------------------------------
*
* Copyright (c) 2016-Present Pivotal Software, Inc
*
*------------------------------------------------------------------------------
*/
#include <R.h>
#include <Rinternals.h>
#include "common/messages/messages.h"
#include "common/comm_channel.h"
#include "common/comm_utils.h"
#include "rcall.h"
#include "rlogging.h"
static SEXP plr_output(volatile int, SEXP args);
SEXP plr_debug(SEXP args) {
return plr_output(DEBUG2, args);
}
SEXP plr_log(SEXP args) {
return plr_output(LOG, args);
}
SEXP plr_info(SEXP args) {
return plr_output(INFO, args);
}
SEXP plr_notice(SEXP args) {
return plr_output(NOTICE, args);
}
SEXP plr_warning(SEXP args) {
return plr_output(WARNING, args);
}
SEXP plr_error(SEXP args) {
return plr_output(ERROR, args);
}
SEXP plr_fatal(SEXP args) {
return plr_output(FATAL, args);
}
static SEXP plr_output(volatile int level, SEXP args) {
plcConn *conn = plcconn_global;
plcMsgLog *msg;
if (plc_is_execution_terminated == 0) {
char *str_msg = strdup(CHAR(asChar(args)));
if (level >= ERROR)
plc_is_execution_terminated = 1;
msg = pmalloc(sizeof(plcMsgLog));
msg->msgtype = MT_LOG;
msg->level = level;
msg->message = str_msg;
plcontainer_channel_send(conn, (plcMessage *) msg);
free(msg);
free(str_msg);
}
/*
* return a legal object so the interpreter will continue on its merry way
*/
return R_NilValue;
}