Example #1
0
        private void LogToFile(string info, loggingLevel logLevel, string memberName, string filePath, int lineNumber)
        {
            try
            {
                if (logWriter == null)
                {
                    Logger.Open(this.programName, this.logLevel, this.logDirectory, true);
                }

                if (logWriter != null)
                {
                    logWriter.BaseStream.Seek(0, SeekOrigin.End);
                    DateTime now = DateTime.Now;

                    string location = "";
                    if (filePath != "")
                    {
                        location = String.Format("Method: {0} Line# {1} File: {2}", memberName, lineNumber, filePath);
                    }

                    logWriter.WriteLine(logLevel.ToString() + " " + location);
                    logWriter.WriteLine("\t\t" + info);
                    logWriter.Flush();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        public Logger(string programName, loggingLevel logLevel, string logDirectory, bool log)
        {
            exceptionList = new List <clsException>();
            infoList      = new List <clsInfo>();

            this.programName  = programName;
            this.logLevel     = logLevel;
            this.logDirectory = logDirectory;
            this.logCreated   = DateTime.Now;
            this.logFilePath  = logDirectory + logCreated.ToString("MM-yyyy");

            current = this;
        }
Example #3
0
 public static void Open(string programName, loggingLevel logLevel, string logDirectory, bool log = false)
 {
     current = new Logger(programName, logLevel, logDirectory, log);
 }