Exemple #1
0
        /// <summary>
        /// Logs an entry to the specified log.
        /// </summary>
        /// <param name="logName">The name of the log.</param>
        /// <param name="loggingLevel">The Severity level.</param>
        /// <param name="message">The message.</param>
        /// <param name="exception">Any exception to be logged.</param>
        /// <exception cref="InvalidLogException">Thrown if <paramref name="logName"/> does not exist.</exception>
        ///
        public static void Logger(string logName, Severity loggingLevel, string message, Log4NetException excp)
        {
            Initialize(LogPath, logName);

            ILog log = LogManager.GetLogger(logName);

            if (log != null)
            {
                LogBase(log, loggingLevel, message, excp);
                //Flush the message queue...
                try
                {
                    for (int indx = 0; indx < waitingLst.Count; indx++)
                    {
                        logItem qItem = (logItem)waitingLst.Dequeue();
                        LogBase(log, qItem.loggingLevel, qItem.message, qItem.obj as Log4NetException);
                    }
                    waitingLst.Clear();
                }
                catch
                {
                    if (waitingLst != null)
                    {
                        waitingLst.Clear();
                    }
                }
            }
        }
Exemple #2
0
 public void Save(logItem logItem)
 {
     _context.logsItens.Add(logItem);
     try
     {
         _context.SaveChanges();
     }
     catch (Exception)
     {
     }
 }
 public void Save(logItem logItem)
 {
     _context.logsItens.Add(logItem);
     try
     {
         _context.SaveChanges();
     }
     catch (Exception)
     {
     }
     //return RedirectToAction("Index", "LogItem");
 }
        private void SaveLog(item item, string tipo)
        {
            var log = new logItem()
            {
                li_dataHora   = DateTime.Now,
                li_preco_novo = item.it_preco_venda,
                li_tipo       = tipo,
                li_descricao  = $"{tipo} do produto { item.it_titulo }. EAN { item.it_ean }",
                li_it_cod     = item.it_cod
            };

            logController.Save(log);
        }
Exemple #5
0
        public ActionResult Save(item item)
        {
            if (item.it_cod == 0)//Nova
            {
                _context.itens.Add(item);
            }
            else//Editando
            {
                var itemExistente = _context.itens.Single(i => i.it_cod == item.it_cod);

                itemExistente.it_titulo       = item.it_titulo;
                itemExistente.it_descricao    = item.it_descricao;
                itemExistente.it_preco_compra = item.it_preco_compra;
                itemExistente.it_ean          = item.it_ean;
                itemExistente.it_preco_venda  = item.it_preco_venda;
                itemExistente.it_min          = item.it_min;
                itemExistente.it_max          = item.it_max;
                itemExistente.it_quantidade   = item.it_quantidade;
                itemExistente.it_status       = item.it_status;
                itemExistente.it_ca_cod       = item.it_ca_cod;
                itemExistente.it_um_cod       = item.it_um_cod;

                itemExistente.it_ca_cod = item.it_ca_cod;
                itemExistente.it_um_cod = item.it_um_cod;

                var log = new logItem()
                {
                    li_dataHora   = DateTime.Now,
                    li_preco_novo = item.it_preco_venda,
                    li_tipo       = "Edição",
                    li_descricao  = $"Alteração do produto { item.it_titulo }. EAN { item.it_ean }",
                    li_it_cod     = item.it_cod
                };

                logController.Save(log);
            }

            try
            {
                _context.SaveChanges();
            }
            catch (Exception)
            {
                return(RedirectToAction("New", "Item"));
            }

            return(RedirectToAction("Index", "Item"));
        }
Exemple #6
0
        private void writeLine(logItem thisLogItem)
        {
            thisLogItem.logText = cleanse(thisLogItem.logText);
            //Console.WriteLine(s);
            Roboto.logWindow.addLogItem(thisLogItem);


            if (initialised && textWriter != null)
            {
                if (thisLogItem.banner == true)
                {
                    textWriter.WriteLine("************************");
                }
                textWriter.WriteLine(thisLogItem.logText);
                if (thisLogItem.banner == true)
                {
                    textWriter.WriteLine("************************");
                }
            }
        }
Exemple #7
0
        /// <summary>
        /// Add an item to the log
        /// </summary>
        /// <param name="thisLogItem"></param>
        public void log(logItem thisLogItem)
        {
            //check logfile correct
            if (initialised && Roboto.Settings.enableFileLogging && DateTime.Now > currentLogFileDate.AddHours(Roboto.Settings.rotateLogsEveryXHours))
            {
                initialised = false;
                try
                {
                    log("Rotating Logs", loglevel.warn, Colors.White, false, true);
                    finalise();
                    initialise();
                }
                catch (Exception e)
                {
                    initialised = false;
                    log("Error rotating logs! File logging disabled. " + e.ToString(), loglevel.critical);
                }
            }

            if (logLastFlushed < DateTime.Now.AddMinutes(-5))
            {
                textWriter.Flush();
                logLastFlushed = DateTime.Now;
                log("Flushed logfile", loglevel.low);
            }


            if (initialised && thisLogItem.level == loglevel.high)
            {
                Roboto.Settings.stats.logStat(new statItem("High Errors", typeof(logging)));
            }

            if (initialised && thisLogItem.level == loglevel.critical)
            {
                Roboto.Settings.stats.logStat(new statItem("Critical Errors", typeof(logging)));
            }


            if (thisLogItem.noLineBreak)
            {
                write(thisLogItem.logText);
                followOnLine = true;
            }
            else
            {
                //clear any trailing lines from write's instead of writelines
                if (followOnLine)
                {
                    writeLine();
                    followOnLine = false;
                }


                //write the main line
                writeLine(thisLogItem);


                //TODO - pause

                /*if (pause)
                 * {
                 *  writeLine(new logItem("Press any key to continue", loglevel.critical, ConsoleColor.Red,false,false,true);
                 *  Console.ReadKey();
                 * }*/
            }
            Console.ResetColor();
        }