示例#1
0
 public virtual void SetInternal(ASafeLog oLog, bool bOverwriteExisting = false)
 {
     lock (ms_oLock) {
         if (m_oLog == null)
         {
             m_oLog = oLog;
         }
         else if (bOverwriteExisting)
         {
             m_oLog = oLog;
         }
     }     // if
 }         // SetInternal
示例#2
0
        public FileLog(
            string sAppName     = null,
            bool bAppend        = false,
            bool bUtcDateInName = false,
            bool bUtcTimeInName = false,
            string sPath        = null,
            ASafeLog oLog       = null
            ) : base(oLog)
        {
            AppName = (sAppName ?? string.Empty).Trim();

            if (this.appName == string.Empty)
            {
                this.appName = Assembly.GetCallingAssembly().GetName().Name;
            }

            sPath = (sPath ?? string.Empty).Trim();

            var oFileName = new StringBuilder(this.appName);

            if (bUtcTimeInName)
            {
                oFileName.Append(DateTime.UtcNow.ToString(".yyyy-MM-dd.HH-mm-ss", CultureInfo.InvariantCulture));
            }
            else if (bUtcDateInName)
            {
                oFileName.Append(DateTime.UtcNow.ToString(".yyyy-MM-dd", CultureInfo.InvariantCulture));
            }

            oFileName.Append(".log");

            string sFileName = (sPath != string.Empty) ? Path.Combine(sPath, oFileName.ToString()) : oFileName.ToString();

            try {
                m_oLogFile = new StreamWriter(sFileName, bAppend, Encoding.UTF8);
            }
            catch (Exception e) {
                throw new LogException("Failed to open a log file " + sFileName, e);
            }             // try

            m_oLock = new object();

            Init();
        }         // constructor
示例#3
0
        public SafeILog(object oCaller, ASafeLog oLog = null) : base(oLog)
        {
            if (ReferenceEquals(oCaller, null))
            {
                return;
            }

            if (oCaller.GetType() == typeof(Type))
            {
                m_oiLog = LogManager.GetLogger(oCaller as Type);
                return;
            }             // if

            if (oCaller is ILog)
            {
                m_oiLog = oCaller as ILog;
                return;
            }             // if

            m_oiLog = LogManager.GetLogger(oCaller.GetType());
        }         // constructor
示例#4
0
        }         // static constructor

        public LegacyLog(ASafeLog oLog = null) : base(oLog)
        {
        }                                                               // constructor
示例#5
0
        }         // Dispose

        protected ASafeLog(ASafeLog oLog = null)
        {
            m_oLog = oLog;
        }         // constructor
示例#6
0
 public ConsoleLog(ASafeLog oLog = null) : base(oLog)
 {
 }                                                               // constructor