C# Class JSNLog.Infrastructure.LevelUtils

Mostra file Open project: mperdeck/jsnlog

Public Methods

Method Description
HighestLevel ( ) : Level

Returns the highest level as given in Level enum.

IntToLevel ( int i ) : Level

Converts a number to a level. Each level is associated with a value. If the number is equal to or lower than a level, but higher than the previous level, than that level is used. So if: TRACE = 1000, DEBUG = 2000, INFO = 3000, WARN = 4000, ERROR = 5000, FATAL = 6000 And the number is: 2500, than this method returns INFO. If the number is greater than FATAL (highest level), than FATAL is returned. If the number is lower than TRACE, than TRACE is returned. This method assumes that the Level enum is sorted by value!

LevelNumber ( string level ) : int

Determines the numeric value of a level. If level is a number, returns the number. If level is a predefined level name, returns number corresponding to that level. Otherwise throws exception.

NamedLevels ( ) : string

Returns a string with all named levels, separated by | This is used by the web site project.

ParseLevel ( string levelString ) : Level?

Parses a string with the name or value of a level.

PredefinedName ( string level ) : string

Returns the friendly name of the given level if possible. If level is a number matching one of the predefined levels, that level's name is returned. Otherwise, level is returned.

ValidateLevel ( string level ) : void

Throws exception if level is not a valid level.

Method Details

HighestLevel() public static method

Returns the highest level as given in Level enum.
public static HighestLevel ( ) : Level
return Level

IntToLevel() public static method

Converts a number to a level. Each level is associated with a value. If the number is equal to or lower than a level, but higher than the previous level, than that level is used. So if: TRACE = 1000, DEBUG = 2000, INFO = 3000, WARN = 4000, ERROR = 5000, FATAL = 6000 And the number is: 2500, than this method returns INFO. If the number is greater than FATAL (highest level), than FATAL is returned. If the number is lower than TRACE, than TRACE is returned. This method assumes that the Level enum is sorted by value!
public static IntToLevel ( int i ) : Level
i int
return Level

LevelNumber() public static method

Determines the numeric value of a level. If level is a number, returns the number. If level is a predefined level name, returns number corresponding to that level. Otherwise throws exception.
public static LevelNumber ( string level ) : int
level string
return int

NamedLevels() public static method

Returns a string with all named levels, separated by | This is used by the web site project.
public static NamedLevels ( ) : string
return string

ParseLevel() public static method

Parses a string with the name or value of a level.
public static ParseLevel ( string levelString ) : Level?
levelString string
return Level?

PredefinedName() public static method

Returns the friendly name of the given level if possible. If level is a number matching one of the predefined levels, that level's name is returned. Otherwise, level is returned.
public static PredefinedName ( string level ) : string
level string
return string

ValidateLevel() public static method

Throws exception if level is not a valid level.
public static ValidateLevel ( string level ) : void
level string
return void