Created
April 14, 2014 15:58
-
-
Save twelverobots/10660783 to your computer and use it in GitHub Desktop.
A Simple ColdFusion Logger object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Created by jason on 3/20/14. | |
| */ | |
| component accessors="true" { | |
| property defaultLogLevel; | |
| property applicationName; | |
| public void function debug(String message, String extraInfo) { | |
| info(argumentCollection = arguments); | |
| } | |
| public void function info(String message, String extraInfo) { | |
| writeCustomLog(arguments.message, arguments.extraInfo, "Information"); | |
| } | |
| public void function alert(String message, String extraInfo) { | |
| warn(argumentCollection = arguments); | |
| } | |
| public void function warn(String message, String extraInfo) { | |
| writeCustomLog(arguments.message, arguments.extraInfo, "Warning"); | |
| } | |
| public void function error(String message, String extraInfo) { | |
| writeCustomLog(arguments.message, arguments.extraInfo, "Error"); | |
| } | |
| public void function fatal(String message, String extraInfo) { | |
| writeCustomLog(arguments.message, arguments.extraInfo, "Fatal"); | |
| } | |
| public void function writeCustomLog(String message, Any extraInfo, String level) { | |
| var logLevel = arguments.level; | |
| var i = ""; | |
| var extraInfoCollection = ""; | |
| if (NOT listFind("Information,Warning,Error,Fatal", arguments.level)) { | |
| logLevel = getDefaultLogLevel(); | |
| } | |
| writelog(text = arguments.message & " Extra info: " & serializeJSON(arguments.extraInfo), file = getApplicationName(), application = true, type = arguments.level); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment