FACT++  1.0
int setLogLevel ( IssueStruct *  issueParam)

Definition at line 2768 of file feeserver.c.

References createLogMessage(), and sprintf().

Referenced by command_handler().

2768  {
2769  int status = -1;
2770  char msg[70];
2771  unsigned int testLogLevel = 0;
2772 
2773  if ((*issueParam).size < sizeof(unsigned int)) {
2774  (*issueParam).size = 0;
2775  createLogMessage(MSG_DEBUG,
2776  "FeeServer command for setting log level contained invalid parameter.",
2777  0);
2778  return FEE_INVALID_PARAM;
2779  }
2780  memcpy(&testLogLevel, (*issueParam).command, sizeof(unsigned int));
2781  // check loglevel for valid data
2782  if (testLogLevel > MSG_MAX_VAL) {
2783 # ifdef __DEBUG
2784  printf("received invalid log level %d\n", testLogLevel);
2785  fflush(stdout);
2786 # endif
2787  createLogMessage(MSG_DEBUG,
2788  "FeeServer command for setting log level contained invalid parameter.",
2789  0);
2790  return FEE_INVALID_PARAM;
2791  }
2792 
2793  status = pthread_mutex_lock(&log_mut);
2794  // discard eventual error
2795  if (status != 0) {
2796 # ifdef __DEBUG
2797  printf("Lock log mutex error: %d\n", status);
2798  fflush(stdout);
2799 # endif
2800  (*issueParam).size = 0;
2801  return FEE_FAILED;
2802  } else {
2803  logLevel = testLogLevel | MSG_ALARM;
2804 
2805  status = pthread_mutex_unlock(&log_mut);
2806  if (status != 0) {
2807 # ifdef __DEBUG
2808  printf("Unlock log mutex error: %d\n", status);
2809  fflush(stdout);
2810 # endif
2811  createLogMessage(MSG_WARNING, "Unable to unlock logger mutex.", 0);
2812  }
2813 
2814 # ifdef __DEBUG
2815  printf("set new logLevel to %d\n", logLevel);
2816  fflush(stdout);
2817 # endif
2818  msg[sprintf(msg, "New log level on FeeServer: %d.", logLevel)] = 0;
2819  createLogMessage(MSG_INFO, msg, 0);
2820 
2821  (*issueParam).size = 0;
2822  return FEE_OK;
2823  }
2824 }
void createLogMessage(unsigned int type, char *description, char *origin)
Definition: feeserver.c:1530
static pthread_mutex_t log_mut
Definition: feeserver.c:272
static unsigned int logLevel
Definition: feeserver.c:211
sprintf(name1,"NewService%d", i)

+ Here is the call graph for this function:

+ Here is the caller graph for this function: