How do I write log messages in Kohana 3.2? - kohana

Ok I've tried searching all over but can't seem to get just a simple straight forward answer.
I want to write log messages (INFO, ERROR, etc.) to the Kohana log file /application/logs/YYYY/MM/DD.php.
How do I do it?

Try the log class add() method: http://kohanaframework.org/3.2/guide/api/Log#add
Call it like this:
Log::instance()->add(Log::NOTICE, 'My Logged Message Here');
For the first parameter (level) use one of the 9 constants defined in the log class

Shuadoc you shouldn't touch system files (all those under system folder).
Change the value in bootstrap.php instead as stated by Ygam
Otherwise, when updates come you'll be in trouble.

Related

Text in Bash terminal getting overwritten! Using JS, Node.js (npms are: inquirer, console.table, and mysql)

Short 10sec video of what is happening: https://drive.google.com/file/d/1YZccegry36sZIPxTawGjaQ4Sexw5zGpZ/view
I have a CLI app that asks a user for a selection, then returns a response from a mysql database. The CLI app is run in node.js and prompts questions with Inquirer.
However, after returning the table of information, the next prompt overwrites the table data, making it mostly unreadable. It should appear on its own lines beneath the rest of the data, not overlap. The functions that gather and return the data are asynchronous (they must be in order to loop), but I have tried it with just a short list of standard synchronous functions for testing purposes, and the same problem exists. I have tried it with and without console.table, and the prompt still overwrites the response, as a console table or object list.
I have enabled checkwinsize in Bash with
shopt -s checkwinsize
And it still persists.
Is it Bash? Is it a problem with Inquirer?
I was having this issue as well. In my .then method of my prompt I was using switch and case to determine what to console log depending on the users selection. Then at the bottom I had an if statement checking to if they selected 'Finish' if they didn't I called the prompt function again, which I named 'questionUser'.
That's where I was having the issue, calling questionUser again was overriding my console logs.
What I did was I wrapped the questionUser call in a setTimeout like this:
if(data.option !== 'Finish'){
setTimeout(() => {
questionUser();
}, 1000);
}
This worked for me and allowed my console log data to not get deleted.
Hopefully if anyone else is having this issue this helps, I couldn't find an answer to this specific question anywhere.

Read in file with client-side clojurescript/re-frame app

I'm writing a client-side application which should read in a file, transform its content and then export the result. To do this, I decided on Re-Frame.
Now, I'm just starting to wrap my head around Re-Frame and cloujurescipt itself and got the following thing to work:
Somewhere in my view functions, I send this whenever a new file gets selected via a simple HTML input.
[:input {:class "file-input" :type "file"
:on-change #(re-frame/dispatch
[::events/file-name-change (-> % .-target .-value)])}]
What I get is something like C:\fakepath\file-name.txt, with fakepath actually being part of it.
My event handler currently only splits the name and saves the file name to which my input above is subscribed to display the selected file.
(re-frame/reg-event-db
::file-name-change
(fn [db [_ new-name]]
(assoc db :file-name (last (split new-name #"\\")))))
Additionally I want to read in the file to later process it locally. Assuming I'd just change my on-change action and the event handler to do this instead, how would I do it?
I've searched for a while but found next to nothing. The only things that came up where other frameworks and such, but I don't want to introduce a new dependency for each and every new problem.
I'm assuming you want to do everything in the client using HTML5 APIs (eg. no actual upload to a server).
This guide from MDN may come handy: https://developer.mozilla.org/en-US/docs/Web/API/File/Using_files_from_web_applications
It seems you can subscribe to the event triggered when the user selects the file(s), then you can obtain a list of said files, and inspect the files contents through the File API: https://developer.mozilla.org/en-US/docs/Web/API/File
In your case, you'll need to save a reference to the FileList object from the event somewhere, and re-use it later.

Netsuite: ReferenceError functionName is not defined

This is probably a stupid one but I have tried all the things I can think of. I am currently getting the below error on my client side script when I try and execute it.
Error: ReferenceError acvt_serialNumber_saveRecord is not defined
On the Script record in Netsuite I have set the saveRecord function as follows:
acvt_serialNumber_saveRecord
The code in the file is:
function acvt_serialNumber_saveRecord(){
/**do stuff */
}
I have reuploaded to code to make sure the right version was in NetSuite. I have added one character to both the script fn name and the fn name on the Script record (as a shot in the dark). I have seen in the Javascript console at runtime that the correct code is in there and I can see the exact function name (I did a ctrl+f for the "undefined" function in the code in the console to make sure spelling was all the same).
NOTHING has worked. I had this code working earlier, but the changes I made were not to this function at all.
Any help is appreciated
Another thing to check is the code that you recently changed. In particular, check for a hanging comma. IE:
var someObj = {
someProp:'somevalue',
};
The comma at the end of 'somevalue' will cause the script to fail, throwing 'undefined' errors.
Have you tried deleting the Script record in NetSuite and re-creating it?
Do you have any library included for that Client Script in netsuite ?
Provide a screen shot of your Netsuite script page
I encounter similar problem like this before, but it was because i called a function which is inside a library file
Thanks

Rails audio_tag

Hello everyone I am trying to get an audio tag to work in rails. I am using the syntax
<%= audio_tag "somesong.mp3", :controls => true %>
However when I utilize this format it throws an error.
This is the output file created by the audio tag.
This is the error that gets thrown in my song folder
Routing Error
No route matches [GET] "/audios/sunshine.ogg"
Try running rake routes for more information on available routes.
This is my routing table that shows the routes I am using.
eric#ubuntu:~/Desktop/Musicband/musicband_app$ rake routes
contacts GET /contacts(.:format) contacts#index new_contact GET /contacts/new(.:format) contacts#new
contact PUT /contacts/:id(.:format) contacts#update
songs GET /songs(.:format) songs#index
POST /songs(.:format) songs#create
new_song GET /songs/new(.:format) songs#new edit_song GET /songs/:id/edit(.:format) songs#edit
song GET /songs/:id(.:format) songs#show
PUT /songs/:id(.:format) songs#update
DELETE /songs/:id(.:format) songs#destroy
groupees GET /groupees(.:format) groupees#index
POST /groupees(.:format) groupees#create new_groupee GET /groupees/new(.:format) groupees#new
edit_groupee GET /groupees/:id/edit(.:format) groupees#edit
groupee GET /groupees/:id(.:format) groupees#show
PUT /groupees/:id(.:format) groupees#update
DELETE /groupees/:id(.:format) groupees#destroy
audio /audio(.:format) landing_pages#music
/contact(.:format) contacts#new
about /about(.:format) landing_pages#about
root / landing_pages#home
I don't know how to fix this audio problem and get it working. Also where is the audio files stored by default? This is kind for a class project that I am trying to get done pretty soon.
So if there is someone out there who knows how to fix this, I would greatly appreciate it.
Thanks.
You haven't set up the appropriate routes in your routes.rb file.
You need to either add resources :audios and have an audios controller set up to handle the request or if audios is an alias for another controller, set that up accordingly.
--edit--
If you want to serve the audio file through a controller you'll need send_file but really I'd recommend just serving static assets from an asset folder instead of through a controller, which just adds overhead. You only need the controller if you're going to add/change sounds.
Read up on the asset pipeline: http://guides.rubyonrails.org/asset_pipeline.html

implementing uploadify in kohana 3

I have a hard time implementing uploadify inside kohana 3, what changes should I make to the originial uploadify.php? just making it the index function in a controller doesn't work and returns a 500 error.
Thank you!
I'm not too sure if this will help, but I spent many hours dealing with uploadify the other day, and one of the tricks was to give back ANY response from the upload controller to let uploadify know that uploading is done.
Solution as simply as this: $this->request->response = "OK";
However, 500 states for interval server error, so the case might be also passing session ID with the 'scriptData' parameter when initializing uploadify, like this:
$('#file_upload').uploadify({'scriptData': {'<?php echo $session_name; ?>': '<?php echo session_id(); ?>'}});
Hope this helps, cheers!
Are you using Uploadify 2.1.x or 3.0 beta?
Anyway, you should be able to use any controller you want as long as you set the parameters in the javascript accordingly. And make sure you're not using a template for the controller dealing with the file uploads.
For instance, if you have a controller "files" and an action "uploadify" at URI /site/files/uploadify you should set the parameter to something like this:
'script' : '/site/files/uploadify',

Resources