private GeneralLogger Bulid(string code) { Dictionary <string, string> module = GetModuleConfig(code); GeneralLogger logger = CreateLogger(module); PutCache(code, logger); return(logDict[code]); }
static void Main(string[] args) { var myTestClass = new MyTestClass(); myTestClass.Run(); var logger = new GeneralLogger(); var providerSettings = new TestJobsProviderSettings { SearchInAssemblyName = "AsyncNet.Selenium.Tests" }; var jobsProvider = new TestJobsProvider(providerSettings); var managerSettings = new JobsManagerSettings(); var jobsManager = new TestJobsManager(jobsProvider, managerSettings); jobsManager.OnStart += (s, e) => logger.Info("PROCESS START"); jobsManager.OnFailed += (s, e) => logger.Info("PROCESS FAILED"); jobsManager.OnFinished += (s, e) => logger.Info("PROCESS FINISHED"); jobsManager.OnActionExecuting += (s, e) => logger.Info("START - " + ((TestCaseJob)s).TestCaseType.Name); jobsManager.OnActionExecuted += (s, e) => logger.Info("STOP - " + ((TestCaseJob)s).TestCaseType.Name); jobsManager.OnActionCanceled += (s, e) => logger.Info("CANCELLED - " + ((TestCaseJob)s).TestCaseType.Name); jobsManager.OnActionFailed += (s, e) => logger.Info("FAILED - " + ((TestCaseJob)s).TestCaseType.Name + " Exception: " + e.Exception.ToString()); jobsManager.OnBackActionExecuting += (s, e) => logger.Info("BACK START - " + ((TestCaseJob)s).TestCaseType.Name); jobsManager.OnBackActionExecuted += (s, e) => logger.Info("BACK STOP - " + ((TestCaseJob)s).TestCaseType.Name); jobsManager.OnBackActionFailed += (s, e) => logger.Info("BACK FAILED - " + ((TestCaseJob)s).TestCaseType.Name + " Exception: " + e.Exception.ToString()); jobsManager.OnStateChanged += (s, e) => logger.Info("STATE CHANGED - " + ((TestCaseJob)s).State.ToString() + " - " + ((TestCaseJob)s).TestCaseType.Name); jobsManager.BeginRun(); bool ask = true; while (ask) { Console.WriteLine("c - Cancel, t - Terminate, q - Quit"); var key = Console.ReadKey().KeyChar; switch (key) { case 'c': jobsManager.Cancel(); break; case 't': jobsManager.Terminate(); break; case 'q': ask = false; break; } } }
private void LoginForm_Load(object sender, EventArgs e) { IDataAccess da = new DataAccessImpl(); ILogger logger = new GeneralLogger(); sl = new SecurityLayerImpl(da, logger); IEnumerable <User> ul = sl.GetUsersList(); cbUsers.Items.AddRange(ul.ToArray()); }
private void PutCache(string code, GeneralLogger logger) { if (!logDict.ContainsKey(code)) { lock (o) { if (!logDict.ContainsKey(code)) { logDict.Add(code, logger); } } } }
private GeneralLogger CreateLogger(Dictionary <string, string> module) { Type t = Assembly.Load(module["assembly"].ToString()).GetType(module["className"].ToString()); GeneralLogger logger = Activator.CreateInstance(t) as GeneralLogger; logger.Code = module["code"]; logger.Name = module["name"]; logger.Path = module["path"].EndsWith("\\") ? module["path"] : module["path"] + "\\"; logger.Level = levelDict[module["logLevel"]]; logger.TimePattern = module["timePattern"]; logger.Slice = Convert.ToDouble(module["slice"]); return(logger); }
public static void Call() { GeneralLogger logger = LoggerFactory.Instance.GetLogger("ZJ"); Task[] task = new Task[60]; for (int i = 0; i < 10; i++) { task[i * 6 + 0] = Task.Run(() => logger.Debug($"debug:我尼玛我尼玛我尼玛我尼玛我尼玛我尼玛{i}")); task[i * 6 + 1] = Task.Run(() => logger.Info($"info:我尼玛我尼玛我尼玛我尼玛我尼玛我尼玛{i}")); task[i * 6 + 2] = Task.Run(() => logger.Warn($"warn:我尼玛我尼玛我尼玛我尼玛我尼玛我尼玛{i}")); task[i * 6 + 3] = Task.Run(() => logger.Fatal($"Fatal:我尼玛我尼玛我尼玛我尼玛我尼玛我尼玛{i}")); task[i * 6 + 4] = Task.Run(() => logger.Error($"Error:我尼玛我尼玛我尼玛我尼玛我尼玛我尼玛{i}")); task[i * 6 + 5] = Task.Run(() => logger.Trace($"Trace:我尼玛我尼玛我尼玛我尼玛我尼玛我尼玛{i}")); Thread.Sleep(100); } Task.WaitAll(task); //logger.Debug("我尼玛"); //Console.WriteLine(new StackTrace(true).GetFrame(0).GetFileName()); }
public void UpdateLockscreen() { string path = lastOrientation == Orientation.Landscape ? config.lcLandscape : config.lcPortrait; if (File.Exists(path)) { // check if the file is already in PictureLibrary FileInfo fi = new FileInfo(path); string myPicturesPath = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); // Allow subfolder if (fi.Directory.FullName.StartsWith(myPicturesPath)) { // if so, directly set DWAS2WinRT.SetLockscreen(fi.FullName.Replace(myPicturesPath, "")); } else { try { // if not, copy the file with a unique name and set Guid g = Guid.NewGuid(); // while (Guid.Empty == g) g = new Guid(); string fname = g.ToString(); fname += fi.Extension; fi.CopyTo(myPicturesPath + @"\" + fname); DWAS2WinRT.SetLockscreen(fname, deleteAfterwards: true); } catch (Exception ex) { if (GeneralLogger.IsInitialized()) { GeneralLogger.WriteLog("Failed to set lock screen. error:" + ex.Message, LogType.ERROR); } notifyIcon.ShowBalloonTip(1000, "DWAS2", "DWAS2 failed to set your lockscreen.".t(lang), WinForms.ToolTipIcon.Error); } } } else { notifyIcon.ShowBalloonTip(1000, "DWAS2", "DWAS2 lockscreen for current orientation does not exist.".t(lang), WinForms.ToolTipIcon.Error); } }
public MainWindow() { InitializeComponent(); // init logger string logpath = System.AppDomain.CurrentDomain.BaseDirectory + @"\DWAS2.log"; GeneralLogger.Initialize(logpath); // read and process configuration config.ReadConfig(); ProcessConfig(); // check hiding if (File.Exists(config.wpLandscape) && File.Exists(config.wpPortrait) && File.Exists(config.lcLandscape) && File.Exists(config.lcPortrait)) { this.shouldHideAtStartup = true; } // read language languages = DWAS2LanguageManager.LoadLanguages(); lang = DWAS2LanguageManager.SelectLanguage(languages, config.language); if (lang.Language.CompareTo(config.language) != 0) { config.language = lang.Language; config.SaveConfig(); } // LANGUAGE IS PROCESSED IN WINDOW_LOADED EVENT HANDLER // read orientation lastOrientation = DWAS2Interop.GetDesktopOrientation(config.reverse); // notify icon InitNotifyIcon(); // initial set UpdateDetection(); // start timer InitTimer(); }
public LoggerDecorator(GeneralLogger logger) { this.logger = logger; }
private static void AddDebug(LogData logData) { GeneralLogger.Debug(FormatLogMsg(logData)); }
private static void AddError(LogData logData) { GeneralLogger.Error(FormatLogMsg(logData)); }
private static void AddInformation(LogData logData) { GeneralLogger.Info(FormatLogMsg(logData)); }