And then I check to see if the value is there (ex. emergency, alert, etc)
if logEvents[sev]~=nilthen
Here is the full code for my library:
local log ={}local logFile ={}local cache =require("IPv2/cache")local os =require("os")local component =require("component")local colors =require("colors")local term =require("term")local gpu = component.gpu
-- LOCAL VARIABLES
local logLevel =0local logEvents ={["EMERGENCY"]= colors.red,["ALERT"]= colors.red,["CRITICAL"]= colors.orange,["ERROR"]= colors.orange,["WARNING"]= colors.yellow,["NOTICE"]= colors.yellow,["DEBUG"]= colors.blue,["INFORMATIONAL"]= colors.lightBlue,}local logLevels ={[0]={"EMERG","ALERT","CRIT","ERR","WARN","NOTICE","INFO","DEBUG",},[1]={"EMERG","ALERT","CRIT","ERR","WARN","NOTICE","INFO",},[2]={"EMERG","ALERT","CRIT","ERR","WARN","NOTICE",},[3]={"EMERG","ALERT","CRIT","ERR","WARN",},[4]={"EMERG","ALERT","CRIT","ERR",},[5]={"EMERG","ALERT","CRIT",},[6]={"EMERG","ALERT",},[7]={"EMERG",},[8]={},}function log.log(...)local arguments ={...}if#arguments >= 2 thenlocal sev =string.upper(arguments[1])local lString ="[".. sev .."] "for k, v in pairs(arguments)do
lString = lString .."[".. v .."] "end
table.insert(logFile, os.clock().." >> ".. lString)for k, v in pairs(logEvents)doprint(k .." > ".. v)endprint("SEV: ".. sev)print(tostring(logEvents[sev]))if logEvents[sev]~=nilthenlocal isInLogLevels =falsefor i=1,#logLevels[logLevel] doprint(logLevels[logLevel][i].." <<>> ".. sev .." <<>> "..string.upper(arguments[1]))if logLevels[logLevel][i]==string.upper(arguments[1])then
isInLogLevels =trueendendif isInLogLevels thenprint("HERE!")
gpu.setForeground(0x00FF00)
gpu.set(1,1,'Hello, world!')print(gpu.setForeground(0x2E86C1).. arguments[2])endendelsereturnfalseendendfunction log.save()
cache.set("log", logFile)endfunction log.get()return logFile
endfunction log.init()
logFile = cache.get("log")endreturn log
When I run it, I have a line where it prints every severity to see what it sees. And it shows every severity EXCEPT Informational. I even changed it from INFO to INFORMATIONAL. I have no clue why it keeps removing that value. Any other value works fine.
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
This is my array:
And then I check to see if the value is there (ex. emergency, alert, etc)
Here is the full code for my library:
When I run it, I have a line where it prints every severity to see what it sees. And it shows every severity EXCEPT Informational. I even changed it from INFO to INFORMATIONAL. I have no clue why it keeps removing that value. Any other value works fine.
Thanks,
lifewcody
Link to post
Share on other sites