Esempio n. 1
0
        /// <summary>-------
        /// <para>Simply Logger object</para>
        /// </summary>
        /// <param name="file_name">Filename to be used as log, optional: default name is "log.log"</param>
        public Logger(String file_name = null, LOGTO logType = LOGTO.FILE)
        {
            if (file_name != null)
            {
                fileName = file_name;
            }

            // Check for file path and create it if needed
            String path = Path.GetDirectoryName(fileName);

            if (!Directory.Exists(path) && path.Trim() != "")
            {
                Directory.CreateDirectory(path);
            }

            this.NoFileText = logType;

            Trace.AutoFlush = true;
            mySource.Switch = new SourceSwitch("SourceSwitch", "Verbose");
        }
Esempio n. 2
0
        /// <summary>-------
        /// <para>Simply Logger object</para>
        /// </summary>
        /// <param name="fileName">Filename to be used as log, optional: default name is "log.log"</param>
        /// <param name="logType">Indicates the type of log - FILE, CONSOLE, CMD, DISABLE</param>
        public Logger(String fileName = null, LOGTO logType = LOGTO.FILE)
        {
            if (fileName != null)
            {
                this.fileName = fileName;
            }

            if (!fileName.Contains("\\"))
            {
                fileName = AppDomain.CurrentDomain.BaseDirectory + fileName;        // Create the file in the exe dir if not specified
            }
            String path = Path.GetDirectoryName(fileName);

            if (!Directory.Exists(path) && path.Trim() != "")                       // Check for file path and create it if needed
            {
                Directory.CreateDirectory(path);
            }

            this.logType = logType;

            if (logType == LOGTO.CONSOLE)
            {
                Trace.AutoFlush = true;
                mySource.Switch = new SourceSwitch("SourceSwitch", "Verbose");
            }

            if (logType == LOGTO.CMD)
            {
                AllocConsole();
                IntPtr         stdHandle      = GetStdHandle(STD_OUTPUT_HANDLE);
                SafeFileHandle safeFileHandle = new SafeFileHandle(stdHandle, true);
                FileStream     fileStream     = new FileStream(safeFileHandle, FileAccess.Write);
                Encoding       encoding       = System.Text.Encoding.GetEncoding(MY_CODE_PAGE);
                StreamWriter   standardOutput = new StreamWriter(fileStream, encoding);
                standardOutput.AutoFlush = true;
                Console.SetOut(standardOutput);
            }
        }
Esempio n. 3
0
 public static void LogTransaction(TransactionsLog objLog, LOGTO enumLog = LOGTO.DATABASE)
 {
     if (log.IsInfoEnabled) log.Info("Logger LogTransaction started..");
     int result = DBLogger.AddTransaction(objLog);
     if (log.IsInfoEnabled) log.Info("Logger LogTransaction ended..");
 }
Esempio n. 4
0
 public static void LogCashCycle(CashCycleLog objLog, LOGTO enumLog = LOGTO.DATABASE)
 {
     int result = DBLogger.AddTxnCashCycle(objLog);
 }
Esempio n. 5
0
 public static void LogEvents(EventLogger objLog, LOGTO enumLog = LOGTO.DATABASE)
 {
     int result = DBLogger.AddEventLog(objLog);
 }