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;
            }
        }
Ejemplo n.º 2
0
        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 void Log(LogLevel level, LogDomain domain, string message)
        {
            if (level < Level || !Domains.HasFlag(domain))
            {
                return;
            }

            var finalStr = MakeMessage($"{domain.ToString()} {message}");

            Console.WriteLine(finalStr); // Console.WriteLine == NSLog
        }
Ejemplo n.º 4
0
 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 || !Domains.HasFlag(domain))
            {
                return;
            }

            var finalStr = MakeMessage($"{domain.ToString()} {message}");

            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.
            }
        }