Jump to content




[ LogAPI ] v1.72 Logging made easier!

api computer

  • You cannot reply to this topic
33 replies to this topic

#1 Goof

  • Members
  • 751 posts

Posted 02 February 2014 - 03:59 PM

LogAPI 1.72 - By Mikkel809h




Have you ever wanted to log things easier, without having to make new functions and new stuffz?

Then try my LoggingAPI!



What it does:

Makes logging easier, just by a few functioncalls


Features:

Store logs into the api's table, and save them later.

Save logs directly.

Specify a custom path

and much more to come...

Debug-variable: Set the variable to true and the api will show debug

When you load the api, it checks if it is outdated.. if it is, it wants you to use log.update() in your program.


Usage:


First of all, you start the api ( Not os.loadAPI )

shell.run("logapi") -- When running this, it creates a global table called "log"

Then you can start using it:

shell.run("logapi")

log.setPath("testPath") -- set your path first.
log.add("Hello_This is a testing log") -- add..

-- other method:

-- add to a new file:
log.setPath("testPath_1") -- set path first
log.store( "Hi", "-SAVE" ) -- store

-- Delete log:

log.delete( "somepath_to_your_log" )

-- Update:

log.update() -- Run this on startup... ( no returns... It directly updates to newest version, if any )



Changelog

v1.72:

Major update of main functions

No more confusing stuff If any, tell me

log.update directly updates. No Printing screen


v0.75:

Update function

Times in logs. ( tell me if something is wrong with this... )


Major Update.

v0.5:

Major release



Download:


Pastebin


CC:


pastebin get 1mwhBiW9 logapi





Happy Logging :D


Edited by Mikk809h, 11 June 2014 - 02:25 PM.


#2 H4X0RZ

  • Members
  • 1,315 posts
  • LocationGermany

Posted 02 February 2014 - 04:51 PM

I like It :)

Maybe add log levels like the ones of Bukkit,for example 'fine','finer','finest' and 'info' :)

#3 surferpup

  • Members
  • 286 posts
  • LocationUnited States

Posted 02 February 2014 - 05:39 PM

This is cool. You could incorporate the functionality of my Real World Time API for snagging real world date and timestamps. Let me know if it useful for your project.

#4 oeed

    Oversimplifier

  • Members
  • 2,095 posts
  • LocationAuckland, New Zealand

Posted 03 February 2014 - 02:21 AM

Saving the log to a file, for some bizarre reason I hadn't thought of that, consdiering 90% of logs are saved to a file.

This way the screen is polluted with stupid 'hello', '123' messages, which are particularly annoying if you're using a buffer.

Posted Image

Edited by oeed, 03 February 2014 - 03:29 AM.


#5 TechMasterGeneral

  • Members
  • 149 posts
  • LocationUnited States

Posted 03 February 2014 - 12:55 PM

This is awesome... I'm gonna try implementing it in my CCMC... if i get it working right i'll add you to the credits

#6 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 03 February 2014 - 03:33 PM

Moved to APIs and Utilities.

#7 Goof

  • Members
  • 751 posts

Posted 06 February 2014 - 10:26 AM

Hello- Im back from a long internet-breakdown... My internet router/modem went totally crazy and i had to buy a new, and as i got that, i also bought some more bandwidth. Yaay!

On topic:

Thanks for all the response, and sorry for the late answer.

View PostFreack100, on 02 February 2014 - 04:51 PM, said:

I like It :)

Maybe add log levels like the ones of Bukkit,for example 'fine','finer','finest' and 'info' :)


Hmm, like a section- saved by the type?


log.add("Hello","warning") -- just a test.. This hasn't been implemented 'yet'

^^ would output:
  -WARNING: "Hello"


Something like that? or could you explain more?

View Postsurferpup, on 02 February 2014 - 05:39 PM, said:

This is cool. You could incorporate the functionality of my Real World Time API for snagging real world date and timestamps. Let me know if it useful for your project.

It sounds really useful, mostly because then it would be able to see what date-time-seconds etc. the log were saved. I don't quite know if im going to code my own real world time api, but to start with, i "Might" use your api and give you some credits:D





Thanks for all responses.

I hope the next release will be uploaded in some days ( or maybe later today? )

#8 surferpup

  • Members
  • 286 posts
  • LocationUnited States

Posted 06 February 2014 - 12:33 PM

View PostMikk809h, on 06 February 2014 - 10:26 AM, said:


It sounds really useful, mostly because then it would be able to see what date-time-seconds etc. the log were saved. I don't quite know if im going to code my own real world time api, but to start with, i "Might" use your api and give you some credits:D


I just thought you might find it useful instead of having to code it yourself. I really don't care about the credits:) If you like it, leave a comment on the page and up vote it.

#9 lebalusch

  • Members
  • 49 posts

Posted 08 June 2014 - 11:18 PM

Noob question alert-

so this is the test script (named test) i made

os.loadAPI("log")

log.add("Hello") -- add "Hello" to the log file
log.delete("testLOG") -- deletes the log file
log.store(...,"-STORE_save_log") -- this functions allows you to store all possible logs into its table.
--And by setting the last parameter, you tell it to save the table with logs.
log.setPath("testLOG") -- Sets the path to your log file. If not exists then it creates a new.
print("done")

so Why does this not work? i have also tried to make the file testLOG just incase it needs the file to exist at the start. all files are store as if you lay a new pc and just edit test. so i guess in path "test/"

Edited by lebalusch, 08 June 2014 - 11:20 PM.


#10 Goof

  • Members
  • 751 posts

Posted 08 June 2014 - 11:51 PM

Hmm

Oh wait... Yeah, its because i forgot to change the usage from the newer version..

Here you go:

os.loadAPI("log")
log.setPath("ss") -- set your path first.
log.add("Hello") -- add..

-- add to a new file:
log.setPath("sa") -- set path first
log.store( "Hi", "-STORE_save_log" ) -- store


Thanks for that report :D


#11 lebalusch

  • Members
  • 49 posts

Posted 09 June 2014 - 11:01 PM

View PostMikk809h, on 08 June 2014 - 11:51 PM, said:

Hmm

Oh wait... Yeah, its because i forgot to change the usage from the newer version..

Here you go:

os.loadAPI("log")
log.setPath("ss") -- set your path first.
log.add("Hello") -- add..

-- add to a new file:
log.setPath("sa") -- set path first
log.store( "Hi", "-STORE_save_log" ) -- store


Thanks for that report :D

thanks for the quick reply. Sadly just using the code that you left i am still getting a error
" log:63: attempt to index ? (a nil value) "
using

  • VERSION_LOGAPI=0.76


#12 Goof

  • Members
  • 751 posts

Posted 10 June 2014 - 02:26 PM

View Postlebalusch, on 09 June 2014 - 11:01 PM, said:

View PostMikk809h, on 08 June 2014 - 11:51 PM, said:

Hmm

Oh wait... Yeah, its because i forgot to change the usage from the newer version..

Here you go:

os.loadAPI("log")
log.setPath("ss") -- set your path first.
log.add("Hello") -- add..

-- add to a new file:
log.setPath("sa") -- set path first
log.store( "Hi", "-STORE_save_log" ) -- store


Thanks for that report :D

thanks for the quick reply. Sadly just using the code that you left i am still getting a error
" log:63: attempt to index ? (a nil value) "
using

  • VERSION_LOGAPI=0.76

New Update! 0.9 ( Made it return false if opening of file didnt work )

Try to reproduce that error... It doesnt seem to happen for me.

Are you using a custom FS?

Are you writing to a readOnly file?

Did you try reboot the computer to reproduce?


Atm im just looking further into the api to find any clues on that "bug"


~ Mikk809h

#13 lebalusch

  • Members
  • 49 posts

Posted 10 June 2014 - 04:28 PM

This is the log file
Spoiler
That is the result now so working.

Things I worked out myself that you might want to put in your instructions up top.
1. you need to make a directory called logapi
2. in that directory you need to make a file called log.
3. log.setPath() function does not mean the path you want the log set to but just the header of the log it writes. This is not very clear maybe a change of name to log.headerPath()
4. line 202 print("type \"log.update\" in your program to update") is a tad confusing when you get it pop up because you would only get it pop up if you have done an update i guess. so i knew i had already called the update. so maybe a little bit of rework with the text in this area.


IDEAS for the future: Apart from making your "how to use" a little bit more clear i would love to see a function that you could set the directory you write too and the name of the file. some thing like log.logPath("/logs/testlog") and log.logName("testlog") although if you are setting the path you could create the file if it does not exist from that i guess.

But thank you in its current format it does the job and does indeed have a use in my future builds, diamonds to you :-)

Edited by lebalusch, 12 June 2014 - 10:52 AM.


#14 Goof

  • Members
  • 751 posts

Posted 10 June 2014 - 05:35 PM

Hello Again.


I've just pushed a new update to the api, ( almost a rewrite )
The only thing, confusing me is what you mean, by the log.logPath.. I think im going to remove the invisible logging feature, since its making me ( and others ) confused of which is which.


New update is comming in .... 5 mins.

Stay tuned


UPDATED to 1.72 - A number of changes, to make it more stable.

Read OP for new usage of my logAPI



Thanks for helping me out, making everything work smoothly.

~Mikk809h

Edited by Mikk809h, 10 June 2014 - 05:49 PM.


#15 lebalusch

  • Members
  • 49 posts

Posted 10 June 2014 - 07:52 PM

View PostMikk809h, on 10 June 2014 - 05:35 PM, said:

Hello Again.


I've just pushed a new update to the api, ( almost a rewrite )
The only thing, confusing me is what you mean, by the log.logPath.. I think im going to remove the invisible logging feature, since its making me ( and others ) confused of which is which.....

....Thanks for helping me out, making everything work smoothly.



ok so the log.logPath() was just an idea for a function to ask me the route to the log file it would want a reply in the () like "/folder1/log" path, route ,link that kind of way of thinking.

As for the helping out your welcome we are a community and i benefit from your work as i get to use it and also see ideas of how to do certain things in your code too. We all benefit. :)

#16 lebalusch

  • Members
  • 49 posts

Posted 10 June 2014 - 09:06 PM

back to nothing working again.
version 1.73

can you please supply the names of what and where you have everything saved.

i can see a possible fault as you have changed the file name to " logapi " but not the code to call anything. should i be using this "logapi.setPath("testPath") " instead of this "log.setPath("testPath")" ??

#17 Goof

  • Members
  • 751 posts

Posted 11 June 2014 - 02:23 PM

View Postlebalusch, on 10 June 2014 - 09:06 PM, said:

back to nothing working again.
version 1.73

can you please supply the names of what and where you have everything saved.

i can see a possible fault as you have changed the file name to " logapi " but not the code to call anything. should i be using this "logapi.setPath("testPath") " instead of this "log.setPath("testPath")" ??

Im going to explain further in details:

My new version is (when runned) Creating a Global table, called "log"

In the table "log" all the functions exist.

So even if the logpath is "/something/WeirdAPI" then you still call it as
log.setPath('E/ETest')


This quick example below, works ingame.

shell.run("logapi") -- my path to the logapi i downloaded

log.setPath("ss") -- set your path first.
log.add("Hello") -- add..

-- add to a new file:
log.setPath("sa") -- set path first
log.store( "Hi", "-SAVE" ) -- store


This update ( 1.73 ) has removed all the confusing stuff ( the same as 1.72 )

But the new thing in 1.7X is that The logAPI itself wont save anything for debugging.
Of course you can enable the debug, to see whats wrong, if anything is wrong.

I have a feeling that you're running in a custom fs, ( maybe an OS? ) , which can ( Not does ), disable some of the fs handlings in my API.

And for your question:

Quote

should i be using this "logapi.setPath("testPath") " instead of this "log.setPath("testPath")" ??
No. You should not, since My API makes a global table ( called "log" ).
You can run all the functions with: log.anyfunction( x )


~Mikkel

#18 lebalusch

  • Members
  • 49 posts

Posted 11 June 2014 - 03:32 PM

Now run it on an emulator so there is no mods interfering
Spoiler
Still not working.

is it possible to have 1.72 the one i had working since you changed it all its stopped working for me.

I run monster FTB
this is the ingame error i get. same line
Spoiler

Edited by lebalusch, 12 June 2014 - 10:52 AM.


#19 Goof

  • Members
  • 751 posts

Posted 11 June 2014 - 08:34 PM

View Postlebalusch, on 11 June 2014 - 03:32 PM, said:

Spoiler
I have no clue why it isnt working.

I just tested this on several emulators, and ingame, but everything works.

As i asked before, are you overwriting anything related to the fs api?

Lemme show you some screenies:

And just a note: I added a tostring() around, when saving the logs... thats why the newest version is 1.736 -- in 1.736 I just made the program check if http was enabled

Did you try to wipe the computer, then only download logapi, then make your test program again?


I really dont know what is causing your troubles. I need ways to reproduce.

Wait... Is HTTP enabled? if so, did you whitelist all websites? Because my API uses a website called:

http://www.timeanddate.com

.. Maybe thats not whitelisted?

Edited by Mikk809h, 11 June 2014 - 08:45 PM.


#20 lebalusch

  • Members
  • 49 posts

Posted 12 June 2014 - 10:47 AM

Hi Mikk809h,
Didn't realise you could white list sites or black list them. I am testing on my own real life laptop. in single player , using FTB monster. when i test your scripts i lay a new computercraft block (gold) so shouldn't be a problem. maybe if you add some code to make a point of white listing it before you try to go to the site this might help. but i have had your script working before you made the big changes. Was you using that HTTP call before the big changes if so its not that being a problem. but i do think you should code in white listing the site before calling it.

p.s how do you do these spoilers. they save on loads of space in comments.

Edited by lebalusch, 12 June 2014 - 10:53 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users