summaryrefslogtreecommitdiffstats
path: root/common/log.h
diff options
context:
space:
mode:
authorilsimo <ilsimo>2005-10-23 21:50:42 +0000
committerilsimo <ilsimo>2005-10-23 21:50:42 +0000
commitba1ea148f47f284b0a0990267fe03de3f36b9d3c (patch)
treea153b2e44bff2a7ecd1d8710aca2e539ede01bc3 /common/log.h
parent2b54d20e6509fbd457445985369e83abc585b17e (diff)
downloadxrdp-proprietary-ba1ea148f47f284b0a0990267fe03de3f36b9d3c.tar.gz
xrdp-proprietary-ba1ea148f47f284b0a0990267fe03de3f36b9d3c.zip
Added logging subsystem
Diffstat (limited to 'common/log.h')
-rw-r--r--common/log.h121
1 files changed, 121 insertions, 0 deletions
diff --git a/common/log.h b/common/log.h
new file mode 100644
index 00000000..ccea0e58
--- /dev/null
+++ b/common/log.h
@@ -0,0 +1,121 @@
+/*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ xrdp: A Remote Desktop Protocol server.
+ Copyright (C) Jay Sorg 2005
+
+ session manager
+ linux only
+
+ log.h: logging code declarations
+
+*/
+
+#ifndef LOG_H
+#define LOG_H
+
+#include "arch.h"
+
+/* logging buffer size */
+#define LOG_BUFFER_SIZE 8192
+
+/* logging levels */
+#define LOG_LEVEL_ALWAYS 0
+#define LOG_LEVEL_ERROR 1
+#define LOG_LEVEL_WARNING 2
+#define LOG_LEVEL_INFO 3
+#define LOG_LEVEL_DEBUG 4
+
+/* startup return values */
+#define LOG_STARTUP_OK 0
+#define LOG_ERROR_MALLOC 1
+#define LOG_ERROR_NULL_FILE 2
+#define LOG_ERROR_FILE_OPEN 3
+#define LOG_ERROR_NO_CFG 4
+#define LOG_ERROR_FILE_NOT_OPEN 5
+
+#ifdef DEBUG
+ #define LOG_DBG(s,args...) log_message(LOG_LEVEL_DEBUG,s,args);
+#else
+ #define LOG_DBG
+#endif
+
+struct log_config
+{
+ char* program_name;
+ char* log_file;
+ int fd;
+ unsigned int log_level;
+ int enable_syslog;
+ unsigned int syslog_level;
+};
+
+/**
+ *
+ * Logs a message. Optionally logs the same message on syslog
+ *
+ * @param lvl The level of the logged message
+ *
+ * @param msg The message to be logged
+ *
+ * @return
+ *
+ */
+int DEFAULT_CC
+log_message(const unsigned int lvl, const char* msg, ...);
+
+/**
+ *
+ * Starts the logging subsystem
+ *
+ * @param progname string to prepend to syslog messages
+ *
+ * @param logfile log file path
+ *
+ * @param loglvl level of messages to log
+ *
+ * @param syslog if set to 0, disables the use of syslog
+ *
+ * @param syslvl level of messages to log to syslog
+ *
+ * @return
+ *
+ */
+int DEFAULT_CC
+log_start(const char* progname, const char* logfile, const unsigned int loglvl,
+ const int syslog, const unsigned int syslvl);
+
+/**
+ *
+ * Shuts down the logging subsystem
+ *
+ */
+void DEFAULT_CC
+log_end();
+
+/**
+ *
+ * Converts a string to a log level
+ *
+ * @s The string to convert
+ *
+ * @return The corresponding level od LOG_LEVEL_DEBUG if error
+ *
+ */
+int DEFAULT_CC
+log_text2level(char* s);
+
+#endif
+