parent
e7981f4831
commit
4e5b4e89cf
|
@ -89,7 +89,7 @@ END:
|
|||
return ret;
|
||||
}
|
||||
|
||||
int modify_authorizing(const char *redirect_path)
|
||||
static int modify_authorizing(const char *redirect_path)
|
||||
{
|
||||
if (chmod(redirect_path, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) < 0) {
|
||||
ULOG_ERR(g_log, "Authorizing of %s which is modified is failure:%s", strerror(errno));
|
||||
|
@ -98,3 +98,19 @@ int modify_authorizing(const char *redirect_path)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int write_log_conf_authorizing(const u8 level, const char *conf_path,
|
||||
const char *conf_file, const char *redirect_path, const char *filter_mod)
|
||||
{
|
||||
if (write_log_conf(level, conf_path, conf_file, redirect_path, filter_mod) != 0) {
|
||||
ULOG_ERR(g_log, "Configure of log which is written is failure");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (modify_authorizing(redirect_path) != 0) {
|
||||
ULOG_ERR(g_log, "Modifying authorizing of %s is failure", redirect_path);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ static level_str_t g_level_array[] = {
|
|||
|
||||
int write_log_conf(const u8 level, const char *conf_path, const char *conf_file,
|
||||
const char *rediect_path, const char *filter_mod);
|
||||
int modify_authorizing(const char *redirect_path);
|
||||
int write_log_conf_authorizing(const u8 level, const char *conf_path,
|
||||
const char *conf_file, const char *redirect_path, const char *filter_mod);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,13 +7,9 @@
|
|||
|
||||
static int config_log_console(const log_console_t *conf)
|
||||
{
|
||||
if (write_log_conf(conf->level, LOG_CONF_PATH, LOG_CONF_COSOLE_FILE_NAME, LOG_REDIRECT_CONSOLE, conf->module_name) != 0) {
|
||||
ULOG_ERR(g_log, "configure of log conosle which is written is failure");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (modify_authorizing(LOG_REDIRECT_CONSOLE) != 0) {
|
||||
ULOG_ERR(g_log, "Modifying authorizing of %s is failure", LOG_REDIRECT_CONSOLE);
|
||||
if (write_log_conf_authorizing(conf->level, LOG_CONF_PATH,
|
||||
LOG_CONF_COSOLE_FILE_NAME, LOG_REDIRECT_CONSOLE, conf->module_name) != 0) {
|
||||
ULOG_ERR(g_log, "Writing console[module:%s] of log is failure", conf->module_name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "ulog_api.h"
|
||||
#include "log_file.h"
|
||||
#include "log_console.h"
|
||||
#include "log_tty.h"
|
||||
#include "rpc_module.h"
|
||||
|
||||
|
||||
|
@ -66,6 +67,13 @@ int main(int argc, char **argv)
|
|||
console.level = LOG_DEBUG;
|
||||
console.on = 1;
|
||||
rpc_conf_log_console(NULL, &console, sizeof(console), NULL);
|
||||
|
||||
|
||||
log_tty_t tty = {0};
|
||||
strcpy(tty.module_name, "111");
|
||||
tty.level = LOG_DEBUG;
|
||||
tty.on = 1;
|
||||
rpc_conf_log_tty(NULL, &tty, sizeof(tty), NULL);
|
||||
END:
|
||||
ulog_close(g_log);
|
||||
return 0;
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "log_tty.h"
|
||||
#include "log_common.h"
|
||||
|
||||
#define LOG_CONF_TTY_FILE_NAME "log-tty.conf"
|
||||
#define LOG_DEV_DIR "/dev"
|
||||
|
||||
static int config_log_tty(const log_tty_t *conf)
|
||||
{
|
||||
DIR *dir;
|
||||
|
||||
if ((dir = opendir(LOG_DEV_DIR)) == NULL) {
|
||||
ULOG_ERR(g_log, "Open dir:[%s] is failure:%d\n", LOG_DEV_DIR, strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct dirent *ptr;
|
||||
while ((ptr = readdir(dir)) != NULL) {
|
||||
if ((strcmp(ptr->d_name, ".") == 0)
|
||||
|| (strcmp(ptr->d_name, "..") == 0)
|
||||
|| (ptr->d_type == DT_DIR)) { ///current dir OR parrent dir
|
||||
ULOG_DEBUG(g_log,"The file:[%s] or directory jump over\n", ptr->d_name);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((strstr(ptr->d_name, "tty") == NULL)
|
||||
|| (strcmp(ptr->d_name, "tty") == 0)
|
||||
|| (strcmp(ptr->d_name, "ttyprintk") == 0)
|
||||
|| (strstr(ptr->d_name, "ttyS") != NULL)) {
|
||||
ULOG_DEBUG(g_log,"The file:[%s] isn't redirected\n", ptr->d_name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
if (write_log_conf_authorizing(conf->level, LOG_CONF_PATH,
|
||||
LOG_CONF_COSOLE_FILE_NAME, LOG_REDIRECT_CONSOLE, conf->module_name) != 0) {
|
||||
ULOG_ERR(g_log, "Writing tty[module:%s] of log is failure", conf->module_name);
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rpc_conf_log_tty(rpc_conn *conn, pointer input, int input_len, pointer data)
|
||||
{
|
||||
u32 need_len = sizeof(log_tty_t);
|
||||
if (input_len < need_len) {
|
||||
ULOG_WARNING(g_log,
|
||||
"The input paramter of rpc log console is needed length of %u, but the actual length is %u",
|
||||
need_len, input_len);
|
||||
return;
|
||||
}
|
||||
|
||||
config_log_tty((const log_tty_t *)input);
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef _LOG_TTY_H
|
||||
#define _LOG_TTY_H
|
||||
|
||||
#include "log_console.h"
|
||||
|
||||
typedef log_console_t log_tty_t;
|
||||
|
||||
void rpc_conf_log_tty(rpc_conn *conn, pointer input, int input_len, pointer data);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue