// Add. Adds a level style to our list of styles. We are passed an name // for the style and a csv from the app.config file to define the various // levels ( see LEVELFORMATS ) public static void Add(String sname, String csvStr) { // split string into parts based on ',' String[] parts = csvStr.Split(new char[] { ',' }); // first two parts are the start & end locations for the text int p = 0; int start = Int32.Parse(parts[p++]); int end = Int32.Parse(parts[p++]); // create the style LogLevelStyle lls = new LogLevelStyle(sname, start, end); // add each level based on the csv string ( we assume these are // in ascending order and set 'level' appropriatly int level = 0; // start with level 0 for (p = 2; p < parts.Length; p += 3) { string tag = parts[p]; string name = parts[p + 1]; string colour = parts[p + 2]; LogLevel l = new LogLevel(tag, name, level++, colour); lls.levels.Add(l); } // add the style to the named list of styles allStyles.Add(sname, lls); }
// Set. Used to set the 'current' level based on the style name public static void Set(String levelName) { if (allStyles.ContainsKey(levelName)) { current = allStyles[levelName]; return; } // oops, name dosn't exist, go for lowest level current = allStyles.Values[0]; }
public static void Set(LogLevelStyle c) { current = c; }