According to http://lists.xiph.org/pipermail/flac/2007-July/000933.html compression level is not stored in FLAC file, only in comments if the encoder (but command line flac encoder doesn't do this) will put it there. Probably you have seen encoder command line like "FLAC -8" in FLAC's comments as I did many times. A compression level consists of settings for different subencoders of FLAC and may vary from one encoder implementation to another. Probably a compression level can be derived by some heuristic search over such settings inside the file, but I never came across a tool that is doing this search... One way to do this is to recompress the file at different comression levels and compare compressed streams sizes, you can even write a script for doing this through a binary search doing 4 compressions at most instead of 8...
Also, according to "flac --help" compression levels are just equivalent to a bunch of settings:
-0, --compression-level-0, --fast Synonymous with -l 0 -b 1152 -r 3
-1, --compression-level-1 Synonymous with -l 0 -b 1152 -M -r 3
-2, --compression-level-2 Synonymous with -l 0 -b 1152 -m -r 3
-3, --compression-level-3 Synonymous with -l 6 -b 4096 -r 4
-4, --compression-level-4 Synonymous with -l 8 -b 4096 -M -r 4
-5, --compression-level-5 Synonymous with -l 8 -b 4096 -m -r 5
-6, --compression-level-6 Synonymous with -l 8 -b 4096 -m -r 6
-7, --compression-level-7 Synonymous with -l 8 -b 4096 -m -e -r 6
-8, --compression-level-8, --best Synonymous with -l 12 -b 4096 -m -e -r 6