Пример #1
0
        public static void Run()
        {
            //default configuration: everything is written to the same file in the same folder:
            Log.Inform("write out of box");
            Log.Thread.Inform("write out of box2");
            Log.Head["test"].Inform("write out of box3");
            Log.Session.Get("GAME")["client"].Inform("write out of box4");
            Log.Session.Get("GAME").Rename("Game");

            //a session-less log which will be continued with the next launch of the application
            Log.Get("history").Inform("session-less log");

            //optional initialization. You will like to perform it at the very beginning of the app.
            Log.Initialize(Log.Mode.FOLDER_PER_SESSION);

            //trivial usage: everything is written to the same file
            Log.Inform("write to the default log of the default session");
            Log.Inform("Root log folder: " + Log.RootDir);

            //more sophisticated usage
            Log.Head["Action1"].Inform0("write to log 'Action1' of the default session");

            //writing thread logs to the default session
            ThreadRoutines.Start(task);
            ThreadRoutines.Start(task);

            //writing to an explicitly created session
            Log.Session logSession_Task = Log.Session.Get("TASK");    //create if not exists
            logSession_Task.Inform("write to the default log of the session '" + logSession_Task.Name + "'");
            Log.Writer log_Task_Subtask = logSession_Task["Subtask"]; //create if not exists
            log_Task_Subtask.Error("write to log '" + log_Task_Subtask.Name + "' of session '" + logSession_Task.Name + "''");
            logSession_Task.Trace("write to the default log of the session '" + logSession_Task.Name + "'");
            logSession_Task.Thread.Inform("write to the thread log " + Log.Thread.Id + " of the session '" + logSession_Task.Name + "'");
            //sometimes you may need to rename a log session:
            logSession_Task.Rename("renamed_TASK");
            //optional; close the handlers and free memory
            logSession_Task.Close(false);

            //writing thread logs to explicitly created sessions
            Task.Start("TASK1");
            Task.Start("TASK2");
        }
Пример #2
0
        public static void Run()
        {
            //default configuration: everything is written to the same file in the same folder:
            Log.Inform("write out of box");
            Log.Thread.Inform("write out of box2");
            Log.Head["test"].Inform("write out of box3");
            Log.Session.Get("GAME")["client"].Inform("write out of box4");
            Log.Session.Get("GAME").Rename("Game");


            //optional; initialize log
            Log.Initialize(Log.Mode.FOLDER_PER_SESSION);//if permissions allow it, log will be created in the executable directory

            //trivial usage: everything is written to the same file
            Log.Inform("write to the default log of the default session");

            //more sophisticated usage is below
            Log.Head["Action1"].Inform0("write to log 'Action1' of the default session");

            //writing thread logs to the default session
            ThreadRoutines.Start(task);
            ThreadRoutines.Start(task);

            //writing to an explicitly created session
            Log.Session logSession_Task = Log.Session.Get("TASK");    //create if not exists
            logSession_Task.Inform("write to the default log of the session '" + logSession_Task.Name + "'");
            Log.Writer log_Task_Subtask = logSession_Task["Subtask"]; //create if not exists
            log_Task_Subtask.Error("write to log '" + log_Task_Subtask.Name + "' of session '" + logSession_Task.Name + "''");
            logSession_Task.Trace("write to the default log of the session '" + logSession_Task.Name + "'");
            logSession_Task.Thread.Inform("write to the thread log " + Log.Thread.Id + " of the session '" + logSession_Task.Name + "'");
            //sometimes you may need to rename a log session:
            logSession_Task.Rename("renamed_TASK");
            //optional; close the handlers and free memory
            logSession_Task.Close(false);

            //writing thread logs to explicitly created sessions
            Task.Start("TASK1");
            Task.Start("TASK2");
        }
        public static void Run()
        {
            var watch = new System.Diagnostics.Stopwatch();

            watch.Start();

            //(!)mandatory; initialize settings
            Config.Reload();

            //modify
            Settings.Server.Host = "1.1.1.1";
            Settings.Server.Port = 10;
            //save on disk
            Settings.Server.Save();
            Log.Inform("The settings are saved to: " + Settings.Server.__Info.File);
            //or, restore the previously saved values
            Settings.Server.Reload();
            //or, reset to initial values
            Settings.Server.Reset();

            editServerByDialog();

            User user = new User {
                Name = "Tom3", Email = "*****@*****.**"
            };

            user.Notify("test");
            Settings.General.Users[user.Name] = user;

            Log.Inform("Settings.Credentials.Key: " + Settings.Credentials.Key);
            Settings.Credentials.Key = "test2";
            Log.Inform("Settings.Credentials.Key: " + Settings.Credentials.Key);

            Log.Inform("Settings.Templates.__TypeVersion: " + Settings.Templates.__TypeVersion);

            Config.Save();

            watch.Stop();
        }
Пример #4
0
 // bogus mailer
 public static void Email(string host, int port, string password, string message)
 {
     Log.Inform("sent message:\r\n" + message);
 }