I am having to parse the Facility and Severity of syslog messages in Python. These values come with each message as a single integer. The severity of the event is 0-7, spe
Try the following
result = FAC & 0x7
The normal way to extract the least significant bits would be to do a bitwise AND with the appropriate mask (7 in this case)
SEV = PRI & 7 FAC = PRI >> 3
Like that.
Just apply a bit mask:
sev = int(pri) & 0x07
(0x07 is 00000111)