private string GetBaseFileName(string baseFileName) { if (baseFileName == null || baseFileName.Length == 0) { return(String.Empty); } return(ChoPropertyManager.ExpandProperties(this, baseFileName)); }
public override IChoProfile ConstructProfile(object target, IChoProfile outerProfile) { lock (_padLock) { string message = ChoPropertyManager.ExpandProperties(this, Message); return(new ChoBufferProfileEx(Condition, null, message, (ChoBaseProfile)outerProfile, true, null)); } }
public override IChoProfile ConstructProfile(object target, IChoProfile outerProfile) { lock (_padLock) { string message = ChoPropertyManager.ExpandProperties(target, Message); return(new ChoProfile(Condition, message)); } }
public override IChoProfile ConstructProfile(object target, IChoProfile outerProfile) { string message = null; if (!String.IsNullOrEmpty(Message)) { message = ChoPropertyManager.ExpandProperties(target, Message); } return(new ChoBufferProfile(Condition, Name, message, (ChoBaseProfile)outerProfile, false, StartActions, StopActions)); }
public string Format(object target, string msg) { try { return(ChoString.ExpandProperties(target, msg, '{', '}', '^', new ChoCustomKeyValuePropertyReplacer(target))); } catch (Exception ex) { return(ChoPropertyManager.FormatException(msg, ex)); } }
public string Format(object target, string msg) { try { return(msg); } catch (Exception ex) { return(ChoPropertyManager.FormatException(msg, ex)); } }
public override IChoProfile ConstructProfile(IChoProfile outerProfile) { lock (_padLock) { string fileName = ChoPropertyManager.Translate(FileName); string directory = ChoPropertyManager.Translate(Directory); string message = ChoPropertyManager.Translate(Message); ChoBufferProfile bufferProfile = null; if (String.IsNullOrEmpty(fileName)) { bufferProfile = new ChoBufferProfile(Condition, (StreamWriter)null, message, outerProfile, false); } else { bufferProfile = new ChoBufferProfile(Condition, ChoFileProfileSettings.GetFullPath(directory, fileName), Mode, message, outerProfile, false); } return(DelayedAutoStart ? ChoBufferProfile.DelayedAutoStart(bufferProfile) : bufferProfile); } }
public bool Initialize(bool beforeFieldInit, object state) { if (beforeFieldInit || String.IsNullOrEmpty(LogDirectory)) { LogDirectory = DefaultLogDirectory; } else { LogDirectory = ChoPropertyManager.ExpandProperties(this, LogDirectory); } if (TurnOn) { if (!Directory.Exists(LogDirectory)) { Directory.CreateDirectory(LogDirectory); } } return(false); }
//private static void SetAsNotDisposed(IChoProfile profile, bool dispose) //{ // if (profile == null) // return; // if (profile is ChoBufferProfile) // ((ChoBufferProfile)profile).CanDispose = dispose; // else if (profile is ChoStreamProfile) // ((ChoStreamProfile)profile).CanDispose = dispose; //} private static string GetProfileName(string name, out MemberInfo memberInfo, out string typeProfileFileName, out ChoProfileAttribute memberProfileAttribute, out ChoProfileAttribute typeProfileAttribute) { typeProfileFileName = null; StackFrame stackFrame = ChoStackTrace.GetStackFrame(typeof(ChoProfile).Namespace); memberInfo = stackFrame.GetMethod(); memberProfileAttribute = null; foreach (ChoProfileAttribute profileAttribute in ChoType.GetMemberAttributesByBaseType <ChoProfileAttribute>(memberInfo)) { if (profileAttribute.Name == name) { memberProfileAttribute = profileAttribute; break; } } ChoProfileAttribute emptyTypeProfileAttribute = null; typeProfileAttribute = null; foreach (ChoProfileAttribute profileAttribute in ChoType.GetAttributes <ChoProfileAttribute>(memberInfo.ReflectedType)) { if (String.IsNullOrEmpty(profileAttribute.Name)) { emptyTypeProfileAttribute = profileAttribute; } if (profileAttribute.Name == name) { typeProfileAttribute = profileAttribute; break; } } if (typeProfileAttribute == null) { if (emptyTypeProfileAttribute == null) { typeProfileFileName = GLOBAL_PROFILE_NAME; } else { typeProfileFileName = "{0}_{1}_{2}_{3}".FormatString(name.IsNullOrEmpty() ? "Default" : name, "Type", ChoThreadLocalStorage.Target == null ? 0 : ChoThreadLocalStorage.Target.GetHashCode(), ChoPropertyManager.ExpandProperties(ChoThreadLocalStorage.Target, emptyTypeProfileAttribute.Name)); } } else { typeProfileFileName = "{0}_{1}_{2}_{3}".FormatString(name.IsNullOrEmpty() ? "Default" : name, "Type", ChoThreadLocalStorage.Target == null ? 0 : ChoThreadLocalStorage.Target.GetHashCode(), ChoPropertyManager.ExpandProperties(ChoThreadLocalStorage.Target, typeProfileAttribute.Name)); } if (memberProfileAttribute != null) { return("{0}_{1}_{2}_{3}".FormatString(name.IsNullOrEmpty() ? "Default" : name, memberInfo.Name, ChoThreadLocalStorage.Target == null ? 0 : ChoThreadLocalStorage.Target.GetHashCode(), ChoPropertyManager.ExpandProperties(ChoThreadLocalStorage.Target, memberProfileAttribute.Name))); } else { return(typeProfileFileName); } }