public LogManager() { this._appender = new NullAppender(); this._resolvers = new LogLevelResolver[0]; this._logProcessId = false; this._logManagedThreadId = false; this._logFrameDepth = 0; this._logExtendedFrame = false; this._logs = new Dictionary<String, Log.Shadow>(); this._lock = new ReaderWriterLock(); }
public static void AddAppender(Appender newAppender) { appenders.Add(newAppender); if ((newAppender is FileAppender) && (mainFileAppender == null)) { mainFileAppender = (FileAppender) newAppender; } if ((newAppender is StandardOutputAppender) && (mainConsoleAppender == null)) { mainConsoleAppender = (StandardOutputAppender) newAppender; } if ((newAppender is TraceAppender) && (mainTraceAppender == null)) { mainTraceAppender = (TraceAppender) newAppender; } }
public void TestReflectPluginMissingDefaultCtor() { var pluginBuilder = new PluginBuilder("Kittyfisto", "Test", "TestReflectPluginMissingDefaultCtor"); var type = pluginBuilder.DefineType("SomeSerializableType", TypeAttributes.Class | TypeAttributes.Public); type.AddInterfaceImplementation(typeof(ISerializableType)); var attribute = pluginBuilder.BuildCustomAttribute(new DataContractAttribute()); type.SetCustomAttribute(attribute); var ctorBuilder = type.DefineConstructor(MethodAttributes.Public, CallingConventions.HasThis, new[] { typeof(object) }); var gen = ctorBuilder.GetILGenerator(); gen.Emit(OpCodes.Ret); var serialize = type.DefineMethod(nameof(ISerializableType.Serialize), MethodAttributes.Public | MethodAttributes.Virtual, CallingConventions.HasThis, typeof(void), new [] { typeof(IWriter) }); serialize.GetILGenerator().Emit(OpCodes.Ret); var deserialize = type.DefineMethod(nameof(ISerializableType.Deserialize), MethodAttributes.Public | MethodAttributes.Virtual, CallingConventions.HasThis, typeof(void), new [] { typeof(IReader) }); deserialize.GetILGenerator().Emit(OpCodes.Ret); type.CreateType(); pluginBuilder.Save(); var scanner = new PluginAssemblyLoader(); var appender = Appender.CaptureEvents("Tailviewer.Archiver.Plugins.PluginAssemblyLoader", Level.Error); scanner.ReflectPlugin(pluginBuilder.FileName); appender.Events.Should().HaveCount(1, "because one serializable type is missing a parameterless constructor and this should've provoked an error"); var error = appender.Events.First(); error.RenderedMessage.Should().Contain(type.FullName); error.RenderedMessage.Should().Contain("is missing a parameterless constructor, you must add one"); }
//private string ClassId => $"{U3DAppSetting.LocAppId}_{UiMeta.RootMeta.TypeId}_CommonLogic"; private void CreateScript() { Appender.Clean(); Appender.AppendPrecomplie( //U3DAppSetting.LocAppId + "Play" ); Appender.AppCsNoteHeader(); Appender.AppendSingleComment("在这里实现UI组件或视图的公共逻辑!"); //Appender.AppendLine($"namespace {U3DAppSetting.LocAppId}Play"); Appender.AppendLine("{"); Appender.ToRight(); //Appender.AppendLine($"public static class {ClassId}"); Appender.AppendLine("{"); Appender.ToLeft(); Appender.AppendCsFooter(); Appender.AppendLine("#endif"); //var path = UiMeta.UICommonLogicScriptPath(U3DAppSetting, ClassId); //IOUtility.TryWriteAllText(path, Appender.ToString()); }
private void InitializeAppender(Boolean writeToLocalFile, Boolean writeToLogEntries, string callerAcctNum, string licenseKey, string connectorName, string folderPath = "") { try { Appender appender = new Appender(); appender.InitializeAppender(writeToLocalFile, writeToLogEntries, callerAcctNum, licenseKey, connectorName, ref appendersInitialized, folderPath); } catch (Exception ex) { LogMessages("-----------------------------------------"); LogMessages("Error while Initializing appenders"); LogMessages(ex.Message); LogMessages(ex.StackTrace); if (ex.InnerException != null) { LogMessages(ex.InnerException.ToString()); } } }
public void Run() { int appenderCount = int.Parse(Console.ReadLine()); appenders = new Appender[appenderCount]; for (int i = 0; i < appenderCount; i++) { string[] appenderInfo = Console.ReadLine().Split(); ILayout currentLayout = layoutFactory.GetInstance(appenderInfo[1]); Appender currentAppender = appenderFactory.GetAppender(appenderInfo[0], currentLayout); if (appenderInfo.Length > 2) { string enumName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(appenderInfo[2].ToLower()); currentAppender.ReportLevel = (ReportLevel)Enum.Parse(typeof(ReportLevel), enumName); } appenders[i] = currentAppender; } Logger myLogger = new Logger(appenders); var command = Console.ReadLine().Split('|'); while (command[0] != "END") { var reportLevel = command[0]; var time = command[1]; var message = command[2]; foreach (var appender in this.appenders) { appender.AppendMessage(time, reportLevel, message); } command = Console.ReadLine().Split('|'); } Console.WriteLine(myLogger); }
private static void FlushAppenders(Logger l) { Enumeration <Appender> allAppenders = l.GetAllAppenders(); while (allAppenders.MoveNext()) { Appender a = allAppenders.Current; if (a is Flushable) { try { ((Flushable)a).Flush(); } catch (IOException ioe) { System.Console.Error.WriteLine(a + ": Failed to flush!" + StringUtils.StringifyException (ioe)); } } } }
public void PageLoaded_WhenRejectionIsSet_ThenCurrentPageIsRefreshed() { const string TEMP_TEST_FILE = "temp1.txt"; File.Delete(TEMP_TEST_FILE); var appender = new Appender(); const string REJECTION_WORD = "REJECT"; const string NEW_LINE_1 = "aaaaaaaaaaaaaa"; const string NEW_LINE_2 = "bbb" + REJECTION_WORD + "cccc"; const string NEW_LINE_3 = "cccccccccccccc" + REJECTION_WORD; const string NEW_LINE_4 = "zzzzzzzzzzzzzzzzzz"; appender.OpenFile(TEMP_TEST_FILE); appender.AppendLine(NEW_LINE_1); appender.AppendLine(NEW_LINE_2); appender.AppendLine(NEW_LINE_3); appender.AppendLine(NEW_LINE_4); appender.CloseFile(); var rejectionList = new List <string> { REJECTION_WORD }; _sut.OpenFile(TEMP_TEST_FILE); _sut.GetFirstPage(); WaitForPage(); Assert.IsNotNull(_currentPage, "Page was not set !"); const int NB_LINES_BEFORE_FILTER = 4; Assert.AreEqual(NB_LINES_BEFORE_FILTER, _currentPage.Lines.Count); _currentPage = null; _sut.RejectionList = rejectionList; WaitForPage(); const int NB_LINES_AFTER_FILTER = 2; Assert.IsNotNull(_currentPage, "Page was not set !"); Assert.AreEqual(NB_LINES_AFTER_FILTER, _currentPage.Lines.Count); }
// Ensure audit log has exactly N entries /// <exception cref="System.IO.IOException"/> private void VerifyAuditLogsCheckPattern(bool expectSuccess, int ndupe, Sharpen.Pattern pattern) { // Turn off the logs Logger logger = ((Log4JLogger)FSNamesystem.auditLog).GetLogger(); logger.SetLevel(Level.Off); // Close the appenders and force all logs to be flushed Enumeration <object> appenders = logger.GetAllAppenders(); while (appenders.MoveNext()) { Appender appender = (Appender)appenders.Current; appender.Close(); } BufferedReader reader = new BufferedReader(new FileReader(auditLogFile)); string line = null; bool ret = true; bool patternMatches = false; try { for (int i = 0; i < ndupe; i++) { line = reader.ReadLine(); NUnit.Framework.Assert.IsNotNull(line); patternMatches |= pattern.Matcher(line).Matches(); ret &= successPattern.Matcher(line).Matches(); } NUnit.Framework.Assert.IsNull("Unexpected event in audit log", reader.ReadLine()); NUnit.Framework.Assert.IsTrue("Expected audit event not found in audit log", patternMatches ); NUnit.Framework.Assert.IsTrue("Expected success=" + expectSuccess, ret == expectSuccess ); } finally { reader.Close(); } }
internal void GetAppendersFromConsole() { var numberOfAppenders = int.Parse(Console.ReadLine()); appenders = new Appender[numberOfAppenders]; for (int i = 0; i < numberOfAppenders; i++) { var input = Console.ReadLine().Split(); ILayout currentLayout = layoutFactory.GetInstance(input[1]); Appender currentAppender = appenderFactory.GetAppender(input[0], currentLayout); if (input.Length > 2) { string enumName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(input[2].ToLower()); currentAppender.ReportLevel = (ReportLevel)Enum.Parse(typeof(ReportLevel), enumName); } this.appenders[i] = currentAppender; } }
public Appender CreateAppender(string type, ReportLevel reportLevel, ILayout layout) { Appender current = null; switch (type) { case nameof(ConsoleAppender): current = new ConsoleAppender(layout); break; case nameof(FileAppender): current = new FileAppender(layout, new LogFile()); break; default: break; } current.ReportLevel = reportLevel; return(current); }
private void AppendExecute() { Appender.AppendCsComment("该方法处理当前交互的业务逻辑。"); var overrideStr = GetBaseClassId() == BASE_HANDLER_TYPE ? null : "override"; Appender.AppendLine($"public {overrideStr} void Execute(object legoControl)"); Appender.AppendLine("{"); Appender.ToRight(); Appender.AppendLine($"if ({lowerId} == null)"); Appender.AppendLine("{"); Appender.ToRight(); Appender.AppendLine($"{lowerId} = ({controlType}) legoControl;"); Appender.ToLeft(); Appender.AppendLine("}"); Appender.AppendLine(); // Appender.AppendLineAtStart("#if UNITY_EDITOR"); // Appender.AppendLine($"LogAppender.AppendInfo(\"{handlerFullName} is invoked!\",\"UI\");"); // Appender.AppendLineAtStart("#endif"); Appender.ToLeft(); Appender.AppendLine("}"); Appender.AppendLine(); }
private static async Task AppendRequest(StringBuilder messageBuilder, HttpResponseMessage response) { var request = response.RequestMessage; messageBuilder.AppendLine(); if (request == null) { messageBuilder.AppendLine("The originated HTTP request was <null>."); return; } messageBuilder.AppendLine("The originated HTTP request was:"); messageBuilder.AppendLine(); messageBuilder.AppendLine($"{request.Method.ToString().ToUpper()} {request.RequestUri} HTTP {request.Version}"); Appender.AppendHeaders(messageBuilder, request.GetHeaders()); AppendContentLength(messageBuilder, request); messageBuilder.AppendLine(); await AppendRequestContent(messageBuilder, request.Content); }
/// <summary> /// Activate the options that were previously set with calls to properties. /// </summary> virtual public void ActivateOptions() { // Close the current asynchronous processing. Close(); // Check the asynchronous layout. if (Layout == null) { throw new LogException(Resources.Strings.AsyncLayoutIsNull); } // Check the asynchronous strategy. if (Strategy == null) { throw new LogException(Resources.Strings.AsyncStrategyIsNull); } // Check the asynchronous target appender. if (Appender == null) { throw new LogException(Resources.Strings.AsyncAppenderIsNull); } _asyncLayout = Layout; _asyncStrategy = Strategy; _asyncAppender = Appender; // Start new asynchronous processing. _asyncStrategy.HandleItem += loggingMessage => Appender.DoAppend(loggingMessage); _asyncStrategy.HandleOverflow += bufferLimit => ErrorHandler.Error(string.Format(Resources.Strings.AsyncQueueOverflow, bufferLimit)); _asyncStrategy.StartProcessing(); // Append header. if (!string.IsNullOrEmpty(_asyncLayout.Header)) { _asyncStrategy.AddItem(_asyncLayout.Header + Environment.NewLine); } }
public static bool SetLogLevel(string name, string newLevelc, bool isLogger = true) { LogLevel newLevel = (LogLevel)uint.Parse(newLevelc); if (newLevel < 0) { return(false); } if (isLogger) { foreach (var logger in loggers.Values) { if (logger.getName() == name) { logger.setLogLevel(newLevel); if (newLevel != LogLevel.Disabled && newLevel < lowestLogLevel) { lowestLogLevel = newLevel; } return(true); } } return(false); } else { Appender appender = GetAppenderByName(name); if (appender == null) { return(false); } appender.setLogLevel(newLevel); } return(true); }
private void AppendCsInitEntitys() { Appender.AppendCsComment("将excel的txt数据源转换为数据列表。"); Appender.AppendLine($"public List<{"IExcelEntity"}> InitEntitys(List<string> rows)"); Appender.AppendLine("{"); Appender.ToRight(); Appender.AppendLine($"var entitys = new List<{"IExcelEntity"}>();"); Appender.AppendLine(" int i = 0;"); Appender.AppendLine("try"); Appender.AppendLine("{"); Appender.ToRight(); Appender.AppendLine("for (; i < rows.Count; i++)"); Appender.AppendLine("{"); Appender.ToRight(); Appender.AppendLine("var strList = rows[i].Split(ExcelDataConstant.Separator,"); Appender.AppendLine(" StringSplitOptions.None).ToList();"); Appender.AppendLine($"var entity = new {ScriptName}();"); Appender.AppendLine("entity.InitEntity(strList);"); Appender.AppendLine("entitys.Add(entity);"); Appender.ToLeft(); Appender.AppendLine("}"); Appender.ToLeft(); Appender.AppendLine("}"); Appender.AppendLine("catch"); Appender.AppendLine("{"); Appender.ToRight(); Appender.AppendLine("Debug.Log($\"生成该表格二进制文件出错,出错行数为第 {i}行\");"); Appender.ToLeft(); Appender.AppendLine("}"); Appender.AppendLine(); Appender.AppendLine("return entitys;"); Appender.ToLeft(); Appender.AppendLine("}"); Appender.AppendLine(); }
static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("usage: <mode(NORMAL|CRAZY)> <path of file to be appended>"); return; } string mode = args[0]; string fileName = args[1]; Console.WriteLine("Appending File: " + fileName); var appender = new Appender(); appender.OpenFile(fileName); if (mode == "NORMAL") { ModeNormal(appender); } else if (mode == "CRAZY") { ModeCrazy(appender); } appender.CloseFile(); }
/// <summary> /// 数据表转换实例初始化方法 /// </summary> private void AppendCsInitEntity() { Appender.AppendCsComment("将excel的一行txt数据源转换为数据实例。"); Appender.AppendLine("public void InitEntity(List<string> cells)"); Appender.AppendLine("{"); Appender.ToRight(); foreach (var info in SheetInfo.FieldInfos) { if (info.FieldType == FieldTypeEnum.Ignore) { continue; } var handler = ExcelFieldHandlerFactory.GetFieldHandler(info.FieldType, ScriptType.Csharp); var csEntityStr = handler.GetCodeStr( DataTableConstant.CsLanguageType, info); Appender.AppendLine(csEntityStr); } Appender.ToLeft(); Appender.AppendLine("}"); Appender.AppendLine(); }
private async Task <bool> ApplyAuthorizationResponseAsync(OpenIdConnectMessage request, OpenIdConnectMessage response) { if (request.IsFormPostResponseMode()) { using (var buffer = new MemoryStream()) using (var writer = new StreamWriter(buffer)) { writer.WriteLine("<!doctype html>"); writer.WriteLine("<html>"); writer.WriteLine("<body>"); // While the redirect_uri parameter should be guarded against unknown values // by IOpenIdConnectServerProvider.ValidateClientRedirectUri, // it's still safer to encode it to avoid cross-site scripting attacks // if the authorization server has a relaxed policy concerning redirect URIs. writer.WriteLine("<form name='form' method='post' action='" + Options.HtmlEncoder.HtmlEncode(response.RedirectUri) + "'>"); foreach (var parameter in response.Parameters) { // Don't include redirect_uri in the form. if (string.Equals(parameter.Key, OpenIdConnectParameterNames.RedirectUri, StringComparison.Ordinal)) { continue; } var name = Options.HtmlEncoder.HtmlEncode(parameter.Key); var value = Options.HtmlEncoder.HtmlEncode(parameter.Value); writer.WriteLine("<input type='hidden' name='" + name + "' value='" + value + "' />"); } writer.WriteLine("<noscript>Click here to finish the authorization process: <input type='submit' /></noscript>"); writer.WriteLine("</form>"); writer.WriteLine("<script>document.form.submit();</script>"); writer.WriteLine("</body>"); writer.WriteLine("</html>"); writer.Flush(); Response.ContentLength = buffer.Length; Response.ContentType = "text/html;charset=UTF-8"; buffer.Seek(offset: 0, loc: SeekOrigin.Begin); await buffer.CopyToAsync(Response.Body, 4096, Context.RequestAborted); return(true); } } else if (request.IsFragmentResponseMode()) { var location = response.RedirectUri; var appender = new Appender(location, '#'); foreach (var parameter in response.Parameters) { // Don't include redirect_uri in the fragment. if (string.Equals(parameter.Key, OpenIdConnectParameterNames.RedirectUri, StringComparison.Ordinal)) { continue; } appender.Append(parameter.Key, parameter.Value); } Response.Redirect(appender.ToString()); return(true); } else if (request.IsQueryResponseMode()) { var location = response.RedirectUri; foreach (var parameter in response.Parameters) { // Don't include redirect_uri in the query string. if (string.Equals(parameter.Key, OpenIdConnectParameterNames.RedirectUri, StringComparison.Ordinal)) { continue; } location = QueryHelpers.AddQueryString(location, parameter.Key, parameter.Value); } Response.Redirect(location); return(true); } return(false); }
public void Run() { int counter = int.Parse(Console.ReadLine()); for (int i = 0; i < counter; i++) { string[] inputInfo = Console.ReadLine() .Split(" ", StringSplitOptions.RemoveEmptyEntries); string appenderType = inputInfo[0]; string layoutType = inputInfo[1]; ReportLevel reportLevel = ReportLevel.Info; if (inputInfo.Length > 2) { reportLevel = Enum.Parse <ReportLevel>(inputInfo[2], true); } ILayout layout = LayoutFactory.CreateLayout(layoutType); Appender appender = AppenderFactory.CreateAppender(appenderType, layout, reportLevel); appenders.Add(appender); } ILogger logger = new Logger(appenders.ToArray()); while (true) { string input = Console.ReadLine(); if (input == "END") { break; } string[] inputInfo = input .Split("|"); string loggerMethodType = inputInfo[0]; string date = inputInfo[1]; string message = inputInfo[2]; if (loggerMethodType == "INFO") { logger.Info(date, message); } else if (loggerMethodType == "WARNING") { logger.Warning(date, message); } else if (loggerMethodType == "ERROR") { logger.Error(date, message); } else if (loggerMethodType == "CRITICAL") { logger.Critical(date, message); } else if (loggerMethodType == "FATAL") { logger.Fatal(date, message); } } Console.WriteLine("Logger info"); foreach (var appender in appenders) { Console.WriteLine(appender); } }
public Synchronized(Appender appender) : base(appender) { this._lock = new Object(); }
public AutoFlush(Appender appender) : base(appender) { // do nothing }
public static void AddAppender(Appender newAppender) { Logger.appenders.Add(newAppender); if (newAppender is FileAppender && Logger.mainFileAppender == null) { Logger.mainFileAppender = (FileAppender)newAppender; } if (newAppender is StandardOutputAppender && Logger.mainConsoleAppender == null) { Logger.mainConsoleAppender = (StandardOutputAppender)newAppender; } if (newAppender is TraceAppender && Logger.mainTraceAppender == null) { Logger.mainTraceAppender = (TraceAppender)newAppender; } }
private static async Task AppendRequestContent(StringBuilder messageBuilder, HttpContent content) { await Appender.AppendContent(messageBuilder, content); }
/// <summary> /// Add an appender to our list /// </summary> /// <param name="newAppender"> /// new appender to add /// </param> public static void AddAppender(Appender newAppender) { appenders.Add(newAppender); }
public CloseShield(Appender appender) : base(appender) { // do nothing }
/// <summary> /// Closes the appender and releases resources. /// </summary> /// <remarks> /// <para> /// Releases any resources allocated within the appender such as file handles, /// network connections, etc. /// </para> /// <para> /// It is a programming error to append to a closed appender. /// </para> /// </remarks> public void Close() { Appender.Close(); }
public AppenderWrapper(Appender appender) { if (appender == null) throw new ArgumentNullException(); this._appender = appender; }
/// <summary> /// Log the logging event in Appender specific way. /// </summary> /// <param name="loggingEvent">The event to log</param> /// <remarks> /// <para> /// This method is called to log a message into this appender. /// </para> /// </remarks> public void DoAppend(LoggingEvent loggingEvent) { Appender.DoAppend(loggingEvent); }
public Filter(Appender appender, LogEntityMatcher matcher) : base(appender) { if (matcher == null) throw new ArgumentNullException(); this._matcher = matcher; }
/// <summary> /// 增加注释 /// </summary> private void AppendNote() { Appender.AppendLine(); Appender.AppendLine("// Excel本地数据表脚本,该脚本为自动创建请勿手动修改!"); Appender.AppendLine(); }
/// <summary> /// Log a message to our logging system /// </summary> /// <param name="level">log level</param> /// <param name="message">message to log</param> /// <param name="t">throwable object</param> private void OurLog(Level level, string message, Exception t) { ts = DateTime.Now; string stamp = ts.ToString(format, CultureInfo.CurrentCulture.DateTimeFormat); System.Text.StringBuilder buf = new System.Text.StringBuilder(level.ToString()); if (showClassNames) { buf.Append(" ["); buf.Append(clazz); buf.Append("]"); } if (showTimestamp) { buf.Append(" "); buf.Append(stamp); } buf.Append(" : "); buf.Append(GetTag()); string prefix = buf.ToString(); if (message != null) { buf.Append(message); } if (t != null) { buf.Append(" : ").Append(t.GetType().FullName).Append(": ").Append(t.Message); } if (appenders.Count == 0) { // by default to stdout System.Console.Out.WriteLine(buf.ToString()); if (t != null) { if (t.StackTrace != null) { foreach (string line in t.StackTrace.Replace("\r", "").Split('\n')) { OurLog(level, prefix + line, null); } } if (t.InnerException != null) { System.Console.Out.WriteLine( string.Format("{0}CAUSED BY - {1}: {2}", prefix, t.InnerException.GetType().FullName, t.InnerException.Message)); if (t.InnerException.StackTrace != null) { foreach (string line in t.InnerException.StackTrace.Replace("\r", "").Split('\n')) { OurLog(level, prefix + line, null); } } } } } else { bool appendToAll = globalLevel.IsGreaterOrEqual(level); lock (appenders.SyncRoot) { for (int i = 0; i < appenders.Count; i++) { Appender a = (Appender)appenders[i]; bool appendToCustom = false; if (a is CustomLogLevelAppender) { CustomLogLevelAppender appender = (CustomLogLevelAppender)a; appendToCustom = appender.CurrentLevel.IsGreaterOrEqual(level); } if (appendToAll || appendToCustom) { if (message != null) { a.Log(prefix + message); } if (t != null) { a.Log(prefix + t.GetType().FullName + ": " + t.Message); if (t.StackTrace != null) { foreach (string line in t.StackTrace.Replace("\r", "").Split('\n')) { a.Log(prefix + line); } } if (t.InnerException != null) { a.Log(prefix + "CAUSED BY - " + t.InnerException.GetType().FullName + ": " + t.Message); if (t.InnerException.StackTrace != null) { foreach (string line in t.InnerException.StackTrace.Replace("\r", "").Split('\n')) { a.Log(prefix + line); } } } } } } } } }
public static void RemoveAppender(Appender appender) { Logger.appenders.Remove(appender); if (appender == Logger.mainFileAppender) { Logger.mainFileAppender = null; } if (appender == Logger.mainConsoleAppender) { Logger.mainConsoleAppender = null; } if (appender == Logger.mainTraceAppender) { Logger.mainTraceAppender = null; } }
private void ConfigureAppenderFromXmlElement(Appender appender, XmlElement element) { Type appenderType = appender.GetType(); foreach (XmlAttribute attrib in element.Attributes) { string name = attrib.LocalName; string value = attrib.InnerText; if (name == "type") continue; PropertyHelper.SetPropertyFromString(appender, name, value); } foreach (XmlNode node in element.ChildNodes) { if (node is XmlElement) { XmlElement el = (XmlElement)node; string name = el.Name; string value = el.InnerXml; PropertyHelper.SetPropertyFromString(appender, name, value); } } }
public void AddAppender(string name, Appender appender) { _appenders[name] = appender; }
public void addAppender(byte id, Appender appender) { appenders[id] = appender; }
/// <summary> /// Collect the appenders from an <see cref="IAppenderAttachable"/>. /// The appender may also be a container. /// </summary> /// <param name="appenderList"></param> /// <param name="appender"></param> private static void CollectAppender(System.Collections.ArrayList appenderList, Appender.IAppender appender) { if (!appenderList.Contains(appender)) { appenderList.Add(appender); IAppenderAttachable container = appender as IAppenderAttachable; if (container != null) { CollectAppenders(appenderList, container); } } }
public ExampleAppender(Dexie dexie, MetaFactory metaFactory, IToastService toastService, Appender appender) { _dexie = dexie; _metaFactory = metaFactory; _toastService = toastService; _appender = appender; }
private void OurLog(Level level, string message, Exception t) { this.ts = DateTime.Now; string str = this.ts.ToString(format, CultureInfo.CurrentCulture.DateTimeFormat); StringBuilder builder = new StringBuilder(level.ToString()); if (showClassNames) { builder.Append(" ["); builder.Append(this.clazz); builder.Append("]"); } if (showTimestamp) { builder.Append(" "); builder.Append(str); } builder.Append(" : "); string str2 = builder.ToString(); builder.Append(message); if (t != null) { builder.Append(" : ").Append(t.GetType().FullName).Append(": ").Append(t.Message); } if (appenders.Count == 0) { Console.Out.WriteLine(builder.ToString()); if (t != null) { if (t.StackTrace != null) { foreach (string str3 in t.StackTrace.Replace("\r", "").Split(new char[] { '\n' })) { this.OurLog(level, str2 + str3, null); } } if (t.InnerException != null) { Console.Out.WriteLine(string.Format("{0}CAUSED BY - {1}: {2}", str2, t.InnerException.GetType().FullName, t.InnerException.Message)); if (t.InnerException.StackTrace != null) { foreach (string str4 in t.InnerException.StackTrace.Replace("\r", "").Split(new char[] { '\n' })) { this.OurLog(level, str2 + str4, null); } } } } } else { bool flag = globalLevel.IsGreaterOrEqual(level); lock (appenders.SyncRoot) { for (int i = 0; i < appenders.Count; i++) { Appender appender = (Appender)appenders[i]; bool flag2 = false; if (appender is CustomLogLevelAppender) { CustomLogLevelAppender appender2 = (CustomLogLevelAppender)appender; flag2 = appender2.CurrentLevel.IsGreaterOrEqual(level); } if (flag || flag2) { appender.Log(str2 + message); if (t != null) { appender.Log(str2 + t.GetType().FullName + ": " + t.Message); if (t.StackTrace != null) { foreach (string str5 in t.StackTrace.Replace("\r", "").Split(new char[] { '\n' })) { appender.Log(str2 + str5); } } if (t.InnerException != null) { appender.Log(str2 + "CAUSED BY - " + t.InnerException.GetType().FullName + ": " + t.Message); if (t.InnerException.StackTrace != null) { foreach (string str6 in t.InnerException.StackTrace.Replace("\r", "").Split(new char[] { '\n' })) { appender.Log(str2 + str6); } } } } } } } } }
private void AppendFooter() { Appender.AppendCsFooter(); }
/// <summary> /// Log the logging message in Appender specific way. /// </summary> /// <param name="loggingMessage">The message to log</param> /// <remarks> /// <para> /// This method is called to log a message into this appender. /// </para> /// </remarks> public void DoAppend(string loggingMessage) { Appender.DoAppend(new LoggingEvent(null, null, null, null, loggingMessage, null)); }
protected override async Task ApplyResponseGrantAsync() { // only successful results of an authorize request are altered if (_clientContext == null || _authorizeEndpointRequest == null || Response.StatusCode != 200) { return; } // only apply with signin of matching authentication type AuthenticationResponseGrant signin = Helper.LookupSignIn(Options.AuthenticationType); if (signin == null) { return; } var returnParameter = new Dictionary <string, string>(); if (_authorizeEndpointRequest.IsAuthorizationCodeGrantType) { DateTimeOffset currentUtc = Options.SystemClock.UtcNow; signin.Properties.IssuedUtc = currentUtc; signin.Properties.ExpiresUtc = currentUtc.Add(Options.AuthorizationCodeExpireTimeSpan); // associate client_id with all subsequent tickets signin.Properties.Dictionary[Constants.Extra.ClientId] = _authorizeEndpointRequest.ClientId; if (!string.IsNullOrEmpty(_authorizeEndpointRequest.RedirectUri)) { // keep original request parameter for later comparison signin.Properties.Dictionary[Constants.Extra.RedirectUri] = _authorizeEndpointRequest.RedirectUri; } var context = new AuthenticationTokenCreateContext( Context, Options.AuthorizationCodeFormat, new AuthenticationTicket(signin.Identity, signin.Properties)); await Options.AuthorizationCodeProvider.CreateAsync(context); string code = context.Token; if (string.IsNullOrEmpty(code)) { _logger.WriteError("response_type code requires an Options.AuthorizationCodeProvider implementing a single-use token."); var errorContext = new OAuthValidateAuthorizeRequestContext(Context, Options, _authorizeEndpointRequest, _clientContext); errorContext.SetError(Constants.Errors.UnsupportedResponseType); await SendErrorRedirectAsync(_clientContext, errorContext); return; } var authResponseContext = new OAuthAuthorizationEndpointResponseContext( Context, Options, new AuthenticationTicket(signin.Identity, signin.Properties), _authorizeEndpointRequest, null, code); await Options.Provider.AuthorizationEndpointResponse(authResponseContext); foreach (var parameter in authResponseContext.AdditionalResponseParameters) { returnParameter[parameter.Key] = parameter.Value.ToString(); } returnParameter[Constants.Parameters.Code] = code; if (!String.IsNullOrEmpty(_authorizeEndpointRequest.State)) { returnParameter[Constants.Parameters.State] = _authorizeEndpointRequest.State; } string location = string.Empty; if (_authorizeEndpointRequest.IsFormPostResponseMode) { location = Options.FormPostEndpoint.ToString(); returnParameter[Constants.Parameters.RedirectUri] = _clientContext.RedirectUri; } else { location = _clientContext.RedirectUri; } foreach (var key in returnParameter.Keys) { location = WebUtilities.AddQueryString(location, key, returnParameter[key]); } Response.Redirect(location); } else if (_authorizeEndpointRequest.IsImplicitGrantType) { string location = _clientContext.RedirectUri; DateTimeOffset currentUtc = Options.SystemClock.UtcNow; signin.Properties.IssuedUtc = currentUtc; signin.Properties.ExpiresUtc = currentUtc.Add(Options.AccessTokenExpireTimeSpan); // associate client_id with access token signin.Properties.Dictionary[Constants.Extra.ClientId] = _authorizeEndpointRequest.ClientId; var accessTokenContext = new AuthenticationTokenCreateContext( Context, Options.AccessTokenFormat, new AuthenticationTicket(signin.Identity, signin.Properties)); await Options.AccessTokenProvider.CreateAsync(accessTokenContext); string accessToken = accessTokenContext.Token; if (string.IsNullOrEmpty(accessToken)) { accessToken = accessTokenContext.SerializeTicket(); } DateTimeOffset?accessTokenExpiresUtc = accessTokenContext.Ticket.Properties.ExpiresUtc; var appender = new Appender(location, '#'); appender .Append(Constants.Parameters.AccessToken, accessToken) .Append(Constants.Parameters.TokenType, Constants.TokenTypes.Bearer); if (accessTokenExpiresUtc.HasValue) { TimeSpan?expiresTimeSpan = accessTokenExpiresUtc - currentUtc; var expiresIn = (long)(expiresTimeSpan.Value.TotalSeconds + .5); appender.Append(Constants.Parameters.ExpiresIn, expiresIn.ToString(CultureInfo.InvariantCulture)); } if (!String.IsNullOrEmpty(_authorizeEndpointRequest.State)) { appender.Append(Constants.Parameters.State, _authorizeEndpointRequest.State); } var authResponseContext = new OAuthAuthorizationEndpointResponseContext( Context, Options, new AuthenticationTicket(signin.Identity, signin.Properties), _authorizeEndpointRequest, accessToken, null); await Options.Provider.AuthorizationEndpointResponse(authResponseContext); foreach (var parameter in authResponseContext.AdditionalResponseParameters) { appender.Append(parameter.Key, parameter.Value.ToString()); } Response.Redirect(appender.ToString()); } }