inserted logger

This commit is contained in:
zolliker
2005-09-02 12:50:33 +00:00
parent 87b4c5bf68
commit 170b24bb44
4 changed files with 54 additions and 6 deletions

View File

@@ -5,6 +5,9 @@
#include <signal.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "myc_mem.h"
#include "myc_err.h"
#include "coc_util.h"
@@ -14,6 +17,7 @@
#include "myc_time.h"
#include "tecs_lsc.h"
#include "tecs_data.h"
#include "logger.h"
/* --- non ANSI signal --- */
#ifndef SIGPIPE
@@ -28,6 +32,7 @@
static SerChannel *ser=NULL;
static char binDir[256]="";
static char logDir[256]="";
static char loggerDir[256]="";
static int logIt=0, use_stdout=0;
static char serverId[32]="tecs";
static int msecTmo=5000;
@@ -170,7 +175,7 @@ static int
lockAlarm,
cntError;
int tim, rdTim; /* actual time, read Time */
static int tim, rdTim; /* actual time, read Time */
static int decod[8]={21,20,17,16,5,4,1,0}; /* for code conversion */
@@ -2777,7 +2782,6 @@ int LogfileHdl(int mode, void *base, int fd) {
return 0;
}
int ExecuteRequest(void) {
if (readTemp) ERR_I(ReadTemp());
ERR_I(CocCallHandlers());
@@ -3003,6 +3007,7 @@ int main(int argc, char *argv[]) {
CocDefStr(serverId, RW); CocHdl(LogfileHdl);
CocDefInt(logIt, RW); CocHdl(LogfileHdl);
CocDefStr(logDir, RW); CocHdl(LogfileHdl);
CocDefStr(loggerDir, RW);
CocDefStr(binDir, RW);
logfileOut(LOG_MAIN ,"%s ", argv[0]);
@@ -3029,6 +3034,9 @@ int main(int argc, char *argv[]) {
} else if ('d'==opt) {
i++;
str_copy(logDir, argv[i]);
} else if ('m'==opt) {
i++;
str_copy(loggerDir, argv[i]);
} else if ('t'==opt) {
i++;
msecTmo=atoi(argv[i]);
@@ -3064,9 +3072,36 @@ int main(int argc, char *argv[]) {
str_copy(statusBuf, "starting up");
logfileStatusBuf(statusBuf);
str_copy(buf, logDir);
str_append(buf, serverId);
if (logDir[0] == '/') {
str_copy(buf, logDir);
} else {
getcwd(buf, sizeof buf);
str_append(buf, "/");
ERR_I(str_append(buf, logDir));
}
ERR_I(str_append(buf, serverId));
if (strcmp(serverId, "tecs") != 0) {
ERR_I(str_append(buf, "/tecs"));
}
logfile=logfileInit(buf, logIt, use_stdout, logIt && use_stdout);
if (loggerDir[0] != '\0') {
if (loggerDir[0] == '/') {
str_copy(buf, loggerDir);
} else {
getcwd(buf, sizeof buf);
str_append(buf, "/");
ERR_I(str_append(buf, loggerDir));
}
if (strcmp(serverId, "tecs") != 0) {
ERR_I(str_append(buf, serverId));
mkdir(buf, S_IRWXU+S_IRGRP+S_IXGRP+S_IROTH+S_IXOTH);
/* do not check return value */
}
str_copy(loggerDir, buf);
LoggerSetDir(loggerDir);
}
CocDefStr(logfile, RD);
logfileOut(LOG_MAIN ,"\n");
logfileWrite(logMask);