コード例 #1
0
 protected override void Log(LoggerLevel loggerLevel, string loggerName, string message, Exception exception)
 {
    System.Diagnostics.Debug.WriteLine("[{0}] {1}", loggerLevel, message);
    if (exception == null)
       return;
    System.Diagnostics.Debug.WriteLine("[{0}] {1}: {2} {3}", loggerLevel, exception.GetType().FullName, exception.Message, exception.StackTrace);
 }
コード例 #2
0
 static void WriteLine(LoggerLevel level, string message)
 {
     ConsoleColor color = ConsoleColor.White;
     switch (level)
     {
         case LoggerLevel.Info:
             color = ConsoleColor.Green;
             break;
         case LoggerLevel.Debug:
             color = ConsoleColor.White;
             break;
         case LoggerLevel.Warn:
             color = ConsoleColor.Yellow;
             break;
         case LoggerLevel.Error:
             color = ConsoleColor.Red;
             break;
         default:
             break;
     }
     if (WaitForInput)
     {
         message = Environment.NewLine + message;
     }
     Console.ForegroundColor = color;
     Console.WriteLine(message);
     Console.ResetColor();
     if (WaitForInput)
     {
         Console.Write(Prefix);
     }
 }
コード例 #3
0
 public BackgroundWorkerService(string sitesPath, string executablePath, ILoggerFactory loggerFactory, LoggerLevel logLevel)
 {
     _executablePath = executablePath;
     _executables = new Dictionary<string, List<Executable>>();
     _executableFinder = new ExecutableFinder(sitesPath);
     _logger = loggerFactory.Create(GetType(), logLevel);
 }
コード例 #4
0
		public override ILogger Create(string name, LoggerLevel level)
		{
			StreamLogger logger =
				new StreamLogger(name, new FileStream(name + ".log", FileMode.Append, FileAccess.Write), Encoding.Default);
			logger.Level = level;
			return logger;
		}
コード例 #5
0
ファイル: Logger.cs プロジェクト: marinehero/microserver
 public static void SetLogLevel(LoggerLevel logLevel)
 {
     lock (lockObject)
     {
         maxLogLevel = logLevel;
     }
 }
コード例 #6
0
 public IISManager(string localSitesPath, string tempSitesPath, ISyncStatusRepository syncStatusRepository, ILoggerFactory loggerFactory, LoggerLevel logLevel)
 {
     _syncStatusRepository = syncStatusRepository;
     _localSitesPath = localSitesPath;
     _tempSitesPath = tempSitesPath;
     _logger = loggerFactory.Create(GetType(), logLevel);
 }
コード例 #7
0
ファイル: Logger.cs プロジェクト: WorldBeard/worldbeardsource
        public void Log(String logMessage, LoggerLevel messageLevel, params ComponentType[] messageComponentTypes)
        {
            if (messageLevel < _logThreshholdLevel) { return; }

            string date = DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss");
            string level = messageLevel == LoggerLevel.NULL ? "   " : messageLevel.ToString();
            string type = messageComponentTypes[0] == ComponentType.NULL ? "   " : ComponentTypeUtil.GetCodeFromType(messageComponentTypes[0]);

            // If no component types are specified, log everything.
            if (componentTypesToLog == null || componentTypesToLog.Count == 0)
            {
                _streamWriter.WriteLine(date + " | " + level + " | " + type + " | " + logMessage);
                _streamWriter.Flush();
                return;
            }
            else // Else, only log messages matching one of the specified component types.
            {
                foreach (ComponentType componentType in messageComponentTypes)
                {
                    if (componentTypesToLog.Contains(componentType))
                    {
                        _streamWriter.WriteLine(date + " | " + level + " | " + type + " | " + logMessage);
                        _streamWriter.Flush();
                        return;
                    }
                }
            }
        }
コード例 #8
0
ファイル: FileLogger.cs プロジェクト: HaKDMoDz/Psy
        public override void Write(string logText, LoggerLevel loggerLevel, string source = "", string category = "", string metaData = "")
        {
            lock (this)
            {
                var useSource = string.Format(
                    "{0}{1}{2}",
                    GlobalSource,
                    (GlobalSource != "" & source != "" ? ":" : ""),
                    source);

                var dateString = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff");

                _file.WriteLine(
                    "{0}|{1}|{2}|{3}|{4}",
                    dateString,
                    useSource,
                    loggerLevel,
                    metaData,
                    logText);

                if (FlushAfterEachWrite)
                {
                    _file.Flush();
                }
            }
        }
コード例 #9
0
 /// <summary>
 /// Instantiates an Azure Web Farm Role.
 /// </summary>
 /// <param name="logFactory">The Castle.Core Logger Factory to use for logging, AzureDiagnosticsTraceListenerFactory by default</param>
 /// <param name="loggerLevel">The Castle.Core Log Level to use for logging, LoggerLevel.Info by default</param>
 /// <param name="diagnosticsLogLevel">The log level to use for Azure Diagnostics, LogLevel.Information by default</param>
 public WebFarmRole(ILoggerFactory logFactory = null, LoggerLevel? loggerLevel = null, LogLevel? diagnosticsLogLevel = null)
 {
     _logFactory = logFactory ?? new AzureDiagnosticsTraceListenerFactory();
     _logLevel = loggerLevel ?? LoggerLevel.Info;
     _logger = _logFactory.Create(GetType(), _logLevel);
     _diagnosticsLogLevel = diagnosticsLogLevel ?? LogLevel.Information;
 }
コード例 #10
0
ファイル: Logger.cs プロジェクト: harlam357/hfm-net
      private static string FormatMessage(LoggerLevel loggerLevel, string message)
      {
         string messageIdentifier = String.Empty;

         switch (loggerLevel)
         {
            case LoggerLevel.Off:
               messageIdentifier = " ";
               break;
            case LoggerLevel.Error:
            case LoggerLevel.Fatal:
               messageIdentifier = "X";
               break;
            case LoggerLevel.Warn:
               messageIdentifier = "!";
               break;
            case LoggerLevel.Info:
               messageIdentifier = "-";
               break;
            case LoggerLevel.Debug:
               messageIdentifier = "+";
               break;
         }

         DateTime dateTime = DateTime.Now;
         return String.Format("[{0}-{1}] {2} {3}", dateTime.ToShortDateString(), dateTime.ToLongTimeString(), messageIdentifier, message);
      }
 // ----------------------------------------------------------------------
 protected override void Output( LoggerLevel level, object message, Exception exception )
 {
     buffer.Append( level.ToString() );
     buffer.Append( ": " );
     buffer.AppendLine( message == null ? "null" : message.ToString() );
     Output( exception );
 }
コード例 #12
0
		public ConsoleLogger(LoggerLevel level, bool console = true, bool trace = false, bool debug = false) :
			base(level)
		{
			_console = console;
			_debug = debug;
			_trace = trace;
			_color = Console.BackgroundColor;
		}
コード例 #13
0
ファイル: WhiteDefaultLogger.cs プロジェクト: EDOlsson/White
 protected override void Log(LoggerLevel loggerLevel, string loggerName, string message, Exception exception)
 {
     Console.Out.WriteLine("[{0} - {3}] '{1}' {2}", loggerLevel, loggerName, message, DateTime.Now.ToLongTimeString());
     if (exception == null)
         return;
     Console.Out.WriteLine("[{0} - {5}] '{1}' {2}: {3} {4}", loggerLevel, loggerName,
         exception.GetType().FullName, exception.Message, exception.StackTrace, DateTime.Now.ToLongTimeString());
 }
コード例 #14
0
ファイル: Logger.cs プロジェクト: punkcoder/JournalApp
        public static void LogEntry(LoggerLevel level, string message, int code)
        {
            LogEntry log = new Code.LogEntry() { Level = level, Message = message, Code = code };

            IDocumentSession conn = JournalDb.GetDBConnection();
            conn.Store(log);
            conn.SaveChanges();
        }
コード例 #15
0
ファイル: Logger.cs プロジェクト: marinehero/microserver
 public static void Initialize(ILogger newLogger, LoggerLevel logLevel)
 {
     if (logger != null)
     {
         throw new InvalidOperationException("Logger may only be initialized once");
     }
     logger = newLogger;
     maxLogLevel = logLevel;
 }
コード例 #16
0
 // ----------------------------------------------------------------------
 public LoggerEvent( LoggerLevel level, string source, string context, string message, Exception caughtException )
 {
     int levelValue = (int)level;
     this.level = levelValue < 0 ? LoggerLevel.Fatal : ( levelValue > 4 ? LoggerLevel.Fatal : level );
     this.source = ArgumentCheck.NonemptyTrimmedString( source, "source" );
     this.context = context ?? string.Empty;
     this.message = message ?? string.Empty;
     this.caughtException = caughtException;
 }
コード例 #17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WhiteLogRedirector"/> class.
        /// </summary>
        /// <param name="name">The name for the logger.</param>
        /// <param name="level">The default log level.</param>
        /// <param name="diagnostics">The object that provides the logging for the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        public WhiteLogRedirector(string name, LoggerLevel level, SystemDiagnostics diagnostics)
            : base(name, level)
        {
            {
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_Diagnostics = diagnostics;
        }
コード例 #18
0
ファイル: Logger.cs プロジェクト: joenjuki/design-patterns
        public void WriteEntry(LoggerLevel level, string format, params object[] args)
        {
            var now = DateTime.Now.ToLongTimeString();

            var message = string.Format(format, args);

            textWriter.WriteLine("[{0}] {1} {2}", now, level, message);
            textWriter.Flush();
        }
コード例 #19
0
		public virtual ILogger Create(Type type, LoggerLevel level)
		{
			if (type == null)
			{
				throw new ArgumentNullException("type");
			}

			return Create(type.FullName, level);
		}
コード例 #20
0
ファイル: Logger.cs プロジェクト: HaKDMoDz/Psy
        /// <summary>
        /// Write to the log.
        /// </summary>
        /// <param name="logText">Text to log</param>
        /// <param name="loggerLevel">Optional.</param>
        public static void Write(string logText, LoggerLevel loggerLevel = LoggerLevel.Debug, string source = "")
        {
            foreach (var logger in Loggers)
            {
                if (!logger.WillHandle(loggerLevel))
                    break;

                logger.Write(logText, loggerLevel, source);
            }
        }
コード例 #21
0
        public LoggersManager(ILoggerFactory fac, LoggerLevel level)
        {
            _level = level;
            _factory = fac;

            _appLogger = new Lazy<ILogger>(() => _factory.Create("Application", _level));
            _webServerLogger = new Lazy<ILogger>(() => _factory.Create("WebServer", _level));
            _dataLogger = new Lazy<ILogger>(() => _factory.Create("DAL", _level));
            _handlersLogger = new Lazy<ILogger>(() => _factory.Create("Handler", _level));
        }
コード例 #22
0
ファイル: ConsoleLogger.cs プロジェクト: brianmatic/n2cms
        /// <summary>
        ///   A Common method to log.
        /// </summary>
        /// <param name = "loggerLevel">The level of logging</param>
        /// <param name = "loggerName">The name of the logger</param>
        /// <param name = "message">The Message</param>
        /// <param name = "exception">The Exception</param>
        protected override void Log(LoggerLevel loggerLevel, String loggerName, String message, Exception exception)
        {
            Console.Out.WriteLine("[{0}] '{1}' {2}", loggerLevel, loggerName, message);

            if (exception != null)
            {
                Console.Out.WriteLine("[{0}] '{1}' {2}: {3} {4}", loggerLevel, loggerName, exception.GetType().FullName,
                                      exception.Message, exception.StackTrace);
            }
        }
コード例 #23
0
ファイル: TraceLogger.cs プロジェクト: vbedegi/Castle.Core
		protected override void Log(LoggerLevel loggerLevel, string loggerName, string message, Exception exception)
		{
			if (exception == null)
			{
				traceSource.TraceEvent(MapTraceEventType(loggerLevel), 0, message);
			}
			else
			{
				traceSource.TraceData(MapTraceEventType(loggerLevel), 0, message, exception);
			}
		}
コード例 #24
0
ファイル: Program.cs プロジェクト: JoakimBrannstrom/IocLab
        private static void RegisterComponents(LoggerLevel loggerLevel)
        {
            SetupComponentRegistrationEvent();

            RegisterLoggers(loggerLevel);

            RegisterProviders();

            RegisterAspects();

            RegisterControllers();
        }
コード例 #25
0
ファイル: Logger.cs プロジェクト: JustDerb/texttoshare
 /// <summary>
 /// Inserts a message into the database with the given message and level of importance.
 /// </summary>
 /// <param name="message">The message for the log.</param>
 /// <param name="level">The level of the given.</param>
 /// <returns>true if the message was successfully logged.</returns>
 /// <seealso cref="LoggerLevel"/>
 public static bool LogMessage(string message, LoggerLevel level)
 {
     Console.WriteLine(DateTime.Now.ToString("HH:mm:ss tt") + " > " + System.Enum.GetName(level.GetType(), level) + ": " + message);
     try
     {
         return controller.LogMessage(message, level);
     }
     catch (Exception ex)
     {
         Console.WriteLine(DateTime.Now.ToString("HH:mm:ss tt") + " > " + System.Enum.GetName(level.GetType(), level) + ": " + ex.Message);
         return false;
     }
 }
コード例 #26
0
ファイル: Logger.cs プロジェクト: yindongfei/bridge.lua
        public Logger(string name, bool useTimeStamp, LoggerLevel loggerLevel, params ILogger[] loggerWriters)
        {
            this.Name = name ?? string.Empty;

            if (loggerLevel == 0)
            {
                loggerLevel = LoggerLevel.Info;
            }

            this.LoggerWriters = loggerWriters.Where(x => x != null).ToList();
            this.UseTimeStamp = useTimeStamp;
            this.LoggerLevel = loggerLevel;
        }
コード例 #27
0
ファイル: LoggerFactory.cs プロジェクト: Jitlee/LPS
 public static void SetLoggerLevel(LoggerLevel level)
 {
     _level = level;
     lock (_thisObject)
     {
         if (_loggerDictionary.Count > 0)
         {
             foreach (var dict in _loggerDictionary)
             {
                 dict.Value.SetLoggerLevel(level);
             }
         }
     }
 }
コード例 #28
0
        public static IContainer BuildContainer(CloudStorageAccount storageAccount, ILoggerFactory logFactory, LoggerLevel logLevel)
        {
            var localTempPath = AzureConfig.GetTempLocalResourcePath();
            var localSitesPath = AzureConfig.GetSitesLocalResourcePath();
            var localExecutionPath = AzureConfig.GetExecutionLocalResourcePath();

            var containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterModule(new RepositoryModule());
            containerBuilder.RegisterModule(new LoggerModule(logFactory, logLevel));
            containerBuilder.RegisterModule(new StorageFactoryModule(storageAccount));
            containerBuilder.RegisterModule(new SyncServiceModule(storageAccount, localTempPath, localSitesPath));
            containerBuilder.RegisterModule(new BackgroundWorkerModule(localSitesPath, localExecutionPath));
            containerBuilder.RegisterModule(new WebDeployServiceModule(storageAccount));

            return containerBuilder.Build();
        }
コード例 #29
0
ファイル: Logger.cs プロジェクト: afit/HVoIPM
 public void Log(string strLogMessage, LoggerLevel level)
 {
     lock (this) {
         string strType = System.Configuration.ConfigurationManager.AppSettings["logType"];
         switch (strType) {
             case "eventlog":
                 EventLogEntryType et;
                 switch (level) {
                     case LoggerLevel.Error:
                         et = EventLogEntryType.Error;
                         break;
                     case LoggerLevel.Information:
                         et = EventLogEntryType.Information;
                         break;
                     case LoggerLevel.Warning:
                         et = EventLogEntryType.Warning;
                         break;
                     default:
                         et = EventLogEntryType.Information;
                         break;
                 }
                 StampEventLogEntry(strLogMessage, et);
                 break;
             case "xml":
                 StampXmlLogEntry(strLogMessage, level);
                 break;
             default:
                 string strFile = "";
                 try {
                     strFile = System.Configuration.ConfigurationManager.AppSettings["logFile"];
                 } catch (System.Configuration.SettingsPropertyNotFoundException) {
                     strFile = System.Environment.CurrentDirectory + "\\debug.log";
                 }
                 if (strFile == "") {
                     strFile = System.Environment.CurrentDirectory + "\\debug.log";
                 } else {
                     strFile = System.Environment.CurrentDirectory + "\\" + strFile;
                 }
                 StreamWriter objLogFile = File.AppendText(strFile);
                 objLogFile.WriteLine(DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss.ffffff") + "|" + level.ToString() + "|" + strLogMessage);
                 objLogFile.Close();
                 break;
         }
     }
 }
コード例 #30
0
        public SyncService(IWebSiteRepository sitesRepository, ISyncStatusRepository syncStatusRepository, CloudStorageAccount storageAccount, string localSitesPath, string localTempPath, IEnumerable<string> directoriesToExclude, IEnumerable<string> sitesToExclude, Func<bool> syncEnabled, IISManager iisManager, ILoggerFactory loggerFactory, LoggerLevel logLevel)
        {
            _sitesRepository = sitesRepository;
            _syncStatusRepository = syncStatusRepository;

            _localSitesPath = localSitesPath;
            _localTempPath = localTempPath;
            _directoriesToExclude = directoriesToExclude;
            _sitesToExclude = sitesToExclude;
            _syncEnabled = syncEnabled;
            _iisManager = iisManager;
            _entries = new Dictionary<string, FileEntry>();
            _siteDeployTimes = new Dictionary<string, DateTime>();
            _logger = loggerFactory.Create(GetType(), logLevel);

            var sitesContainerName = AzureRoleEnvironment.GetConfigurationSettingValue(Constants.WebDeployPackagesBlobContainerKey).ToLowerInvariant();
            _container = storageAccount.CreateCloudBlobClient().GetContainerReference(sitesContainerName);
            _container.CreateIfNotExist();
        }
コード例 #31
0
 public ILogger Create(Type type, LoggerLevel level)
 {
     throw new NotImplementedException();
 }
コード例 #32
0
 /// <summary>
 ///   Creates a new logger, getting the logger name from the specified type.
 /// </summary>
 ILogger ILoggerFactory.Create(Type type, LoggerLevel level)
 {
     return(Create(type, level));
 }
コード例 #33
0
 public new IExtendedLogger Create(string name, LoggerLevel level)
 {
     return(new ExtendedConsoleLogger(name, level));
 }
コード例 #34
0
        private void UpdateColors(LoggerLevel level)
        {
            ConsoleColors colors = this.colorMappingsCache[level];

            console.SetColors(colors);
        }
コード例 #35
0
 /// <summary>
 ///   Implementors output the log content by implementing this method only.
 ///   Note that exception can be null
 /// </summary>
 /// <param name = "loggerLevel"></param>
 /// <param name = "loggerName"></param>
 /// <param name = "message"></param>
 /// <param name = "exception"></param>
 protected abstract void Log(LoggerLevel loggerLevel, String loggerName, String message, Exception exception);
コード例 #36
0
 /// <summary>
 /// Not implemented, NLog logger levels cannot be set at runtime.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="level">The level.</param>
 /// <returns></returns>
 /// <exception cref="NotImplementedException" />
 public override framework.ILogger Create(String name, LoggerLevel level)
 {
     throw new NotImplementedException("Logger levels cannot be set at runtime. Please review your configuration file.");
 }
コード例 #37
0
 private void Log(LoggerLevel loggerLevel, String message, Exception exception)
 {
     Log(loggerLevel, Name, message, exception);
 }
コード例 #38
0
        }         // Log

        // ----------------------------------------------------------------------
        public void Log(LoggerLevel level, object message, Exception exception)
        {
        }         // Log
コード例 #39
0
        }         // FatalFormat

        // ----------------------------------------------------------------------
        public void Log(LoggerLevel level, object message)
        {
        }         // Log
コード例 #40
0
ファイル: NLogFactory.cs プロジェクト: slamj1/Core-3
 /// <summary>
 ///   Not implemented, NLog logger levels cannot be set at runtime.
 /// </summary>
 /// <param name="name"> The name. </param>
 /// <param name="level"> The level. </param>
 /// <returns> </returns>
 /// <exception cref="NotImplementedException" />
 public override Core.Logging.ILogger Create(String name, LoggerLevel level)
 {
     throw new NotSupportedException("Logger levels cannot be set at runtime. Please review your configuration file.");
 }
コード例 #41
0
 public void SetCategoryLevel(LoggerLevel level, string categoryPath)
 {
     PInvokeUtils.ThrowIfResult(NativeMethods.Logger_SetCategoryLevel(this.Interface, (uint)level, categoryPath));
 }
コード例 #42
0
 public static void LogMessage(LoggerLevel level, uint messageId, string text, InspectableAdapter pParameter)
 {
     PInvokeUtils.ThrowIfResult(NativeMethods.Logger_LogMessage((uint)level, messageId, text, pParameter != null ? pParameter.Interface:IntPtr.Zero));
 }
コード例 #43
0
 protected override void Log(LoggerLevel loggerLevel, string message, Exception exception)
 {
 }
コード例 #44
0
 public LoggingFacility WithLevel(LoggerLevel level)
 {
     loggerLevel = level;
     return(this);
 }
コード例 #45
0
 public ILogger Create(Type type, LoggerLevel level)
 {
     return(new ConsoleLogger(type.Name, level));
 }
コード例 #46
0
        }         // Log

        // ----------------------------------------------------------------------
        public void LogFormat(LoggerLevel level, string format, params object[] args)
        {
        }         // LogFormat
コード例 #47
0
 public ConsoleFactory(LoggerLevel level)
 {
     this.level = level;
 }
コード例 #48
0
 public ILogger Create(String name, LoggerLevel level)
 {
     return(new ConsoleLogger(name, level));
 }
コード例 #49
0
 public abstract ILogger Create(String name, LoggerLevel level);
コード例 #50
0
ファイル: FileLoggerWriter.cs プロジェクト: zwmyint/Bridge
 private bool CheckLoggerLevel(LoggerLevel level)
 {
     return(level <= LoggerLevel);
 }
コード例 #51
0
 protected LevelFilteredLogger(String loggerName, LoggerLevel loggerLevel) : this(loggerLevel)
 {
     ChangeName(loggerName);
 }
コード例 #52
0
ファイル: FileLoggerWriter.cs プロジェクト: zwmyint/Bridge
 private void WriteOrBufferLine(LoggerLevel level, string s)
 {
     WriteOrBuffer(level, s, true);
 }
コード例 #53
0
 protected LevelFilteredLogger(LoggerLevel loggerLevel)
 {
     level = loggerLevel;
 }
コード例 #54
0
 public ILogger Create(string name, LoggerLevel level)
 {
     throw new NotImplementedException();
 }
コード例 #55
0
        }         // LogFormat

        // ----------------------------------------------------------------------
        public void LogFormat(LoggerLevel level, IFormatProvider provider, string format, params object[] args)
        {
        }         // LogFormat
コード例 #56
0
 public override ILogger Create(string name, LoggerLevel level)
 {
     return(InternalCreate(name, level));
 }
コード例 #57
0
 /// <summary>
 ///   Creates a new extended logger.
 /// </summary>
 public abstract IExtendedLogger Create(string name, LoggerLevel level);
コード例 #58
0
 /// <summary>
 ///   Creates a new logger.
 /// </summary>
 ILogger ILoggerFactory.Create(string name, LoggerLevel level)
 {
     return(Create(name, level));
 }
コード例 #59
0
 private ILogger InternalCreate(string name, LoggerLevel level)
 {
     return(new TraceLogger(name, level));
 }
コード例 #60
0
 /// <summary>
 /// Build a new trace logger based on the named TraceSource
 /// </summary>
 /// <param name="name">The name used to locate the best TraceSource. In most cases comes from the using type's fullname.</param>
 /// <param name="level">The default logging level at which this source should write messages. In almost all cases this
 /// default value will be overridden in the config file. </param>
 public TraceLogger(string name, LoggerLevel level) : base(name, level)
 {
     Initialize();
     Level = MapLoggerLevel(traceSource.Switch.Level);
 }