public override void MinAndMaxCorrectlySet() { var domain = new LogDomain(LogDomainTest.minimum, LogDomainTest.maximum); Assert.Equal(LogDomainTest.maximum, domain.Maximum); Assert.Equal(LogDomainTest.minimum, domain.Minimum); }
internal static IReadOnlyDictionary <LogDomain, LogLevel> GetLogLevels(LogDomain domains) { var retVal = new Dictionary <LogDomain, LogLevel>(); if (domains.HasFlag(LogDomain.Couchbase)) { retVal[LogDomain.Couchbase] = Log.To.Couchbase.Level; } if (domains.HasFlag(LogDomain.Database)) { retVal[LogDomain.Database] = Log.To.Database.Level; } if (domains.HasFlag(LogDomain.Query)) { retVal[LogDomain.Query] = Log.To.Query.Level; } if (domains.HasFlag(LogDomain.Replicator)) { retVal[LogDomain.Replicator] = Log.To.Sync.Level; } if (domains.HasFlag(LogDomain.Network)) { retVal[LogDomain.Network] = (LogLevel)Native.c4log_getLevel(Log.LogDomainBLIP); } return(retVal); }
public void MutationDistributionDoesNotDepartFromNormalDistributionInLogSpace() { // Build up unbounded domain. var domain = new LogDomain(1.0 / double.MaxValue, double.MaxValue); // Fix the value to mutate and the variance percentage. Allele <double> valueToMutate = new Allele <double>(3.4); double variancePercentage = 0.000001; // Collect results in log space for a lot of mutations. int numberRuns = 1000; double[] mutationsInLogSpace = new double[numberRuns]; for (int i = 0; i < numberRuns; i++) { mutationsInLogSpace[i] = Math.Log((double)domain.MutateGeneValue(valueToMutate, variancePercentage).GetValue()); } // Apply the Kolmogorov-Smirnov test. double stdDev = Math.Sqrt(variancePercentage * (Math.Log(domain.Maximum) - Math.Log(domain.Minimum))); KolmogorovSmirnovTest normalityTest = new KolmogorovSmirnovTest( sample: mutationsInLogSpace, hypothesizedDistribution: new NormalDistribution(mean: Math.Log(valueToMutate.GetValue()), stdDev: stdDev)); Assert.False( double.IsNaN(normalityTest.PValue) || normalityTest.Significant, $"Mutation was found to be not normal by the Kolmogorov-Smirnov test with significance level of {normalityTest.Size}."); }
public void Log(LogLevel level, LogDomain domain, string message) { if (level < Level || !Domains.HasFlag(domain)) { return; } var finalStr = MakeMessage($"{domain.ToString()} {message}"); switch (level) { case LogLevel.Error: global::Android.Util.Log.Error("CouchbaseLite", finalStr); break; case LogLevel.Warning: global::Android.Util.Log.Warn("CouchbaseLite", finalStr); break; case LogLevel.Info: global::Android.Util.Log.Info("CouchbaseLite", finalStr); break; case LogLevel.Verbose: case LogLevel.Debug: global::Android.Util.Log.Verbose("CouchbaseLite", finalStr); break; } }
public void GenerateRandomGeneValueDoesNotDepartFromUniformDistributionInLogSpace() { // Build up logarithmically spaced domain from e to e^10. double minimumExponent = 1; double maximumExponent = 10; var domain = new LogDomain(Math.Exp(minimumExponent), Math.Exp(maximumExponent)); // Collect results of value generation. int numberRuns = 10000; double[] generatedValues = new double[numberRuns]; for (int i = 0; i < numberRuns; i++) { Allele <double> generated = domain.GenerateRandomGeneValue(); generatedValues[i] = Math.Log(generated.GetValue()); } // Apply the Anderson-Darling test. AndersonDarlingTest uniformTest = new AndersonDarlingTest( generatedValues, new UniformContinuousDistribution(minimumExponent, maximumExponent)); Assert.False( uniformTest.Significant, $"Random generation was found to be not uniform in log space by the Anderson-Darling test with significance level of {uniformTest.Size}."); }
private static string MakeMessage(string message, LogLevel level, LogDomain domain) { var dateTime = DateTime.Now.ToLocalTime().ToString("yyyy-M-d hh:mm:ss.fffK"); var threadId = Thread.CurrentThread.Name ?? Thread.CurrentThread.ManagedThreadId.ToString(); return($"{dateTime} [{threadId}]| {level.ToString().ToUpperInvariant()}) [{domain}] {message}"); }
private void CreateAndAddLogger([NotNull] string domainStr, LogDomain domain, int index) { Debug.Assert(domainStr != null); var logger = new DomainLogger(domainStr, domain); _allLoggers[index] = logger; }
void Start() { _startTime = 0; var rnd = new System.Random(); filename = $"log_{rnd.Next()}.txt"; try { _stream = new StreamWriter(filename); } catch (System.Exception ex) { print(ex.Message); } if (_stream != null) { lock (_buffer) { foreach (string s in _buffer) { _stream.WriteLine(s); } } _buffer = null; _general = register("general"); } }
/// <summary> /// Sets the log level for the given domains(s) /// </summary> /// <param name="domains">The domains(s) to change the log level for</param> /// <param name="level">The level to set the logging to</param> public static void SetLogLevel(LogDomain domains, LogLevel level) { if (domains.HasFlag(LogDomain.Couchbase)) { Log.To.Couchbase.Level = level; Log.To.LiteCore.Level = level; } if (domains.HasFlag(LogDomain.Database)) { Log.To.Database.Level = level; } if (domains.HasFlag(LogDomain.Query)) { Log.To.Query.Level = level; } if (domains.HasFlag(LogDomain.Replicator)) { Log.To.Sync.Level = level; } if (domains.HasFlag(LogDomain.Network)) { Native.c4log_setLevel(Log.LogDomainBLIP, (C4LogLevel)level); Native.c4log_setLevel(Log.LogDomainWebSocket, (C4LogLevel)level); } }
public override void ToStringShowsMinimumAndMaximum() { var domain = new LogDomain(LogDomainTest.minimum, LogDomainTest.maximum); Assert.Equal( FormattableString.Invariant($"[{domain.Minimum}, {domain.Maximum}] (in log space)"), domain.ToString()); }
public override void DomainSizeIsCorrect() { var boundedDomain = new LogDomain(LogDomainTest.minimum, LogDomainTest.maximum); Assert.Equal( double.PositiveInfinity, boundedDomain.DomainSize); }
public void Log(LogLevel level, LogDomain domain, string message) { if (level < Level || !Domains.HasFlag(domain)) { return; } var finalStr = MakeMessage(message, level, domain); Console.WriteLine(finalStr); // Console.WriteLine == NSLog }
public Action GetStopElapsed(MethodBase method, LogDomain edomain, string address = null) { var sw = new Stopwatch(); sw.Start(); return () => { sw.Stop(); Elapsed(method, sw.ElapsedMilliseconds, edomain, address); sw.Reset(); }; }
public ILog GetLogger(LogDomain domain) { var repository = domain.ToString(); try { return LogManager.GetLogger(repository, "default"); } catch { lock (FileBase.Getlocker(repository)) { try { return LogManager.GetLogger(repository, "default"); } catch { try { var loggerRepository = LogManager.CreateRepository(repository); var log4NetBaseDirectory = AppConfig.Log4NetBaseDirectory; if (string.IsNullOrEmpty(log4NetBaseDirectory)) { log4NetBaseDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "/../", "Log4NetBaseDirectory"); } foreach (var filter in Filters) { var fileAppender = new RollingFileAppender { Name = domain + "_" + filter.Key + "_FileAppender", LockingModel = new FileAppender.MinimalLock(), File = log4NetBaseDirectory, AppendToFile = true, RollingStyle = RollingFileAppender.RollingMode.Date, DatePattern = "/yyyy-MM-dd'/" + domain + "/'yyyy-MM-dd HH'" + filter.Key + ".log'", StaticLogFileName = false, Layout = Layout }; fileAppender.AddFilter(filter.Value); fileAppender.ActivateOptions(); BasicConfigurator.Configure(loggerRepository, fileAppender); } return LogManager.GetLogger(repository, "default"); } catch { return default(ILog); } } } } }
public void Log(LogLevel level, LogDomain domain, string message) { if (level < Level) { return; } try { _output.WriteLine($"{level.ToString().ToUpperInvariant()}) {domain} {message}"); } catch (Exception) { // _output is busted, the test is probably already finished. Nothing we can do } }
public void Log(LogLevel level, LogDomain domain, string message) { if (level < Level || !Domains.HasFlag(domain)) { return; } Console.WriteLine($"{level.ToString().ToUpperInvariant()}) {domain} {message}"); if (Debugger.IsAttached) { Debug.WriteLine($"{level.ToString().ToUpperInvariant()}) {domain} {message}"); } }
/// <summary> /// Log Errors /// </summary> /// <param name="level"></param> /// <param name="msg"></param> public static void LogError(string msg, LogDomain domain) { if (logDomain == LogDomain.None) { return; } else if (logDomain == LogDomain.All) { UnityEngine.Debug.LogError("<b><color=#002fff>[CombatDebugger]: </color></b>" + msg); } else if (domain == logDomain) { UnityEngine.Debug.LogError("<b><color=#002fff>[CombatDebugger]: </color></b>" + msg); } }
public void Log(LogLevel level, LogDomain domain, string message) { if (level < Level || !Domains.HasFlag(domain)) { return; } var finalStr = MakeMessage(message, level, domain); Console.WriteLine(finalStr); if (Debugger.IsAttached) { Debug.WriteLine(finalStr); } }
public void LogDmainToLog_MappingIsValid() { // Arrange var logDmain = new LogDomain() { Id = "Tets Id", Date = "20.08.2020", Message = "Test Message" }; // Act var log = mapper.Map <Log>(logDmain); // Assert Assert.AreEqual(logDmain.Id, log.Id); Assert.AreEqual(logDmain.Date, log.Date); Assert.AreEqual(logDmain.Message, log.Message); }
public LogDomain register(string aName, bool aEnabled = true) { LogDomain result; if (!_domains.ContainsKey(aName)) { result = new LogDomain(aName, aEnabled); result.Added += onRecordAdded; result.add("init"); _domains.Add(aName, result); } else { result = _domains[aName]; } return(result); }
public void MutationStaysInDomain() { // Initialize bounded domain. var domain = new LogDomain(LogDomainTest.minimum, LogDomainTest.maximum); // Fix the value to mutate and the variance percentage. Allele <double> valueToMutate = new Allele <double>(LogDomainTest.maximum - 1); double variancePercentage = 1.0; // For a lot of tries: int numberRuns = 1000; for (int i = 0; i < numberRuns; i++) { // Mutate and check that the mutated value is in the domain. IAllele mutatedGeneValue = domain.MutateGeneValue(valueToMutate, variancePercentage); Assert.True( domain.ContainsGeneValue(mutatedGeneValue), $"Value {mutatedGeneValue} was generated by mutation and is not contained in {domain}"); } }
public void Log(LogLevel level, LogDomain domain, string message) { if (level < Level || !Domains.HasFlag(domain)) { return; } var finalStr = MakeMessage(message, level, domain); try { if (Debugger.IsAttached) { Debug.WriteLine(finalStr); } Console.WriteLine(finalStr); } catch (ObjectDisposedException) { // On UWP the console can be disposed which means it is no longer // available to write to. Nothing we can do except ignore. } }
public LogViewModel() { _logDomain = new LogDomain(); }
public void Error(CoreMethodInfo methodInfo, LogDomain domain, object returnValue, params string[] messages) { NAction.BeginInvoke(CoreUtil.GetIp(), methodInfo, domain, LogType.Error, returnValue, messages, null, null); }
public void Elapsed(MethodBase method, long elapsedMilliseconds, LogDomain edomain, string address = null) { Client.Debug(method, edomain, null, address, string.Format(@"{0}.{1} finished, used {2} ms.", method.GetDeclaringFullName(), method.Name, elapsedMilliseconds)); }
public void Info(MethodBase declaringType, LogDomain domain, object returnValue, string address, params string[] messages) { MAction.BeginInvoke(CoreUtil.GetIp(), declaringType, domain, LogType.Info, returnValue, address, messages, null, null); }
public void Log(LogLevel level, LogDomain domain, string message) { // handle the message, for example piping it to // a third party framework }
public static void Error(MethodBase declaringType, LogDomain domain, object returnValue, string address, params string[] messages) { MAction.BeginInvoke(IpBase.GetIp(), declaringType, domain, LogType.Error, returnValue, address, messages, null, null); }
public static void Info(CoreMethodInfo methodInfo, LogDomain domain, object returnValue, params string[] messages) { NAction.BeginInvoke(IpBase.GetIp(), methodInfo, domain, LogType.Info, returnValue, messages, null, null); }
private static void Log(string ip, MethodBase declaringType, LogDomain domain, LogType logtype, object returnValue, string address, params string[] messages) { var log = LoggerConfig.Instance.GetLogger(domain); var message = new StringBuilder(); message.Append("[" + ip + "][" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "]"); message.Append("\t\n"); if (!string.IsNullOrEmpty(address)) { message.Append("address:"); message.Append(address); message.Append("\t\n"); } if (returnValue != null) { message.Append("Result:"); message.Append(returnValue.ToJson()); message.Append("\t\n"); } if (messages.Length > 0) message.Append(string.Join("\t\n", messages) + "\t\n"); switch (logtype) { case LogType.Error: log.Error(message); break; case LogType.Debug: log.Debug(message); break; case LogType.Info: log.Info(message); break; } }
private static void Log(string ip, CoreMethodInfo methodInfo, LogDomain domain, LogType logtype, object returnValue, params string[] messages) { var log = LoggerConfig.Instance.GetLogger(domain); try { var message = new StringBuilder(); message.Append("[" + ip + "][" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "]"); message.Append("\t\n"); if (methodInfo.ParamList != null && methodInfo.ParamList.Count > 0) { message.Append("param:"); message.Append(methodInfo.ParamList.ToJson()); message.Append("\t\n"); } if (!string.IsNullOrEmpty(methodInfo.Address)) { message.Append("address:"); message.Append(methodInfo.Address); message.Append("\t\n"); } if (returnValue != null) { message.Append("Result:"); message.Append(returnValue.ToJson()); message.Append("\t\n"); } if (messages.Length > 0) message.Append(string.Join("\t\n", messages) + "\t\n"); switch (logtype) { case LogType.Error: log.Error(message); break; case LogType.Debug: log.Debug(message); break; case LogType.Info: log.Info(message); break; } } catch (Exception ex) { Error(MethodBase.GetCurrentMethod(), domain, logtype, null, string.Empty, ex.ToString()); } }
internal DomainLogger(string domainStr, LogDomain domain) { Subdomain = domainStr ?? "Default"; Domain = domain; }
private static string MakeMessage(string message, LogLevel level, LogDomain domain) { var threadId = Thread.CurrentThread.Name ?? Thread.CurrentThread.ManagedThreadId.ToString(); return($"[{threadId}]| {level.ToString().ToUpperInvariant()}) [{domain}] {message}"); }