コード例 #1
0
    public CFileLogOutput()
    {
        CAPP.GetInstance().OnAppApplicationQuit += Close;
        this.mWritingLogQueue = new Queue <CLog.LogData> ();
        this.mWaitingLogQueue = new Queue <CLog.LogData> ();
        this.mLogLock         = new object();
        System.DateTime now     = System.DateTime.Now;
        string          logName = string.Format("C{0}{1}{2}{3}{4}{5}",
                                                now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);
        string logPath = string.Format("{0}/{1}/{2}.txt", mDevicePersistentPath, LogPath, logName);

        if (File.Exists(logPath))
        {
            File.Delete(logPath);
        }
        string logDir = Path.GetDirectoryName(logPath);

        if (!Directory.Exists(logDir))
        {
            Directory.CreateDirectory(logDir);
        }
        this.mLogWriter           = new StreamWriter(logPath);
        this.mLogWriter.AutoFlush = true;
        this.mIsRunning           = true;
        this.mFileLogThread       = new Thread(new ThreadStart(WriteLog));
        this.mFileLogThread.Start();
    }
コード例 #2
0
ファイル: CLog.cs プロジェクト: YanboWang76/TouchDemoNeo
    private CLog()
    {
        Application.logMessageReceived         += LogCallback;
        Application.logMessageReceivedThreaded += LogMultiThreadCallback;

        this.logTypeLevelDict = new Dictionary <LogType, LogLevel>
        {
            { LogType.Log, LogLevel.LOG },
            { LogType.Warning, LogLevel.WARNING },
            { LogType.Assert, LogLevel.ASSERT },
            { LogType.Error, LogLevel.ERROR },
            { LogType.Exception, LogLevel.ERROR },
        };

        this.uiOutputLogLevel   = LogLevel.LOG;
        this.fileOutputLogLevel = LogLevel.ERROR;
        this.mainThreadID       = Thread.CurrentThread.ManagedThreadId;
        this.logOutputList      = new List <ILogOutput>
        {
            new CFileLogOutput(),
        };
        CAPP.GetInstance().OnAppGUI     += OnGUI;
        CAPP.GetInstance().OnAppDestory += OnDestroy;
    }