XCGLogger does not colorise in debug window - xcglogger

The Github Readme mentions possibility of colours in debug. Despite configuration of the XcodeColors plugin, what else is needed to get colorised output there?

Use:
log.xcodeColorsEnabled = true
when setting up your log object to explicitly turn on colours. Relying on the environment variable isn't great for iOS apps since you have to add it manually in your project. The environment variable works better for OS X apps since you can set it in your .profile etc and have it work for all projects.

For iOS projects, the current version of Xcode (7.3) and XCGLogger (3.3) requires the following line as hinted at by Dave Wood:
log.xcodeColorsEnabled = true
You can put it in didFinishLaunchingWithOptions in AppDelegate.swift after
let log = XCGLogger.defaultInstance()
log.setup(.Debug, showThreadName: true, showLogLevel: true, showFileNames: true, showLineNumbers: true, writeToFile: nil, fileLogLevel: nil)
and then test with
log.info("App started")

Related

How can I troubleshoot Launch Darkly SDK when it fails to get flag values?

I'm trying to set up a simple Launch Darkly integration in .NET but it isn't working. The code seems to run just fine, but it doesn't actually get the flag value. It always returns false regardless of whether I turn the flag on or off in my Launch Darkly dashboard.
Here's my code:
LdClient client = new LdClient("my sdk key");
var user = LaunchDarkly.Sdk.User.WithKey("12345");
var anonymous = LaunchDarkly.Sdk.User.Builder(Session.SessionID).Anonymous(true).Build();
bool enabledForUser = client.BoolVariation("website-poc", user);
bool enabledForAnonymous = client.BoolVariation("website-poc", anonymous);
client.Dispose();
The variables "enabledForUser" and "enabledForAnonymous" always return false. How can I troubleshoot the issue? What are some possible reasons why it's not working? (Note: the client object's "Initialized" property shows up as true, so I assume that means the connection was successful.)
Here's what my flag looks like on the Launch Darkly dashboard. The green "On" toggle means that it should be returning true, right?
I figured out the issue. I was using the SDK key for the wrong project. You can use the yellow drop-down on the dashboard to see which project you're working with.

What module can strip debugs in webpack solutions?

I am running a reactjs app with gulp/webpack and tried this:
https://github.com/yahoo/strip-loader.
However it does not work( throws errors in my reactjs code). How to get it working or what is another solution?
EDIT
I added this to the loaders section of the webpack.config:
new webpack.optimize.UglifyJsPlugin({
drop_debug: true
})
I have installed the plugin with npm but it does not filter the debugger statements from my reactjs code?
You can use UglifyJsPlugin() and pass the drop_debugger: true property.
To utilize this property you need to pass it to the compress property inside of the options argument.
new webpack.optimize.UglifyJsPlugin(
compressor: {
drop_debugger: true
}
);
This is an UglifyJS specific property and webpack can pass those directly through compress. Ironically looking at the source of the plugin it can also take the property compressor as an alt property.
you can use strip-loader plugin in webpack.
var WebpackStripLoader = require('strip-loader');
WebpackStripLoader.loader('console.log', 'console.error', 'debugger')

Chrome browser not caching js files while debugging extjs application

So far i was able to set
'disableCaching: false'
in Ext.Loader.config(in app.js) and debug extjs applications on chrome browser.
But now, on inspecting the source, i see that the files have filename.js?dc=1123123 and every time the files are fetched from remote and not cached. So i am unable to set breakpoints and debug run-time on browser.
Please note that this scenario is when i do a browser refresh.
Plz let me know how i can resolve this issue.
Set disableCacheing to false in app.js before Ext.application({...
Ext.Loader.setConfig({
disableCaching: false
});
This will remove _dc cache param from requests that are getting files.
For disabling _dc on XHR Ext.Ajax requests use
Ext.Ajax.disableCaching = false;
And for proxy communication with server use noCache property on Ext.data.proxy.Server class.
noCache: true
You can also set cache config in app.json file.
"loader": {
// This property controls how the loader manages caching for requests:
//
// - true: allows requests to receive cached responses
// - false: disable cached responses by adding a random "cache buster"
// - other: a string (such as the build.timestamp shown here) to allow
// requests to be cached for this build.
//
"cache": "${build.timestamp}",
// When "cache" is not true, this value is the request parameter used
// to control caching.
//
"cacheParam": "_dc"
}
Also if using Chrome Dev Tools for debugging take a look at disableCache on Networks tab and if using FF use CTRL + F5 insted F5 to reload page
Add ?cache=false to the end of your URL to temporarily disable caching on a per-request basis.
Setting Ext.Loader configuration is one thing. There is also something called Ext.Boot which is used before loader is up and running. Boot has his own disableCaching setting. It defaults to something like this:
disableCaching: (/[?&](?:cache|disableCacheBuster)\b/i.test(location.search) ||
!(/http[s]?\:/i.test(location.href)) ||
/(^|[ ;])ext-cache=1/.test(doc.cookie)) ? false :
true,
Probably files with dc appended to url are loaded by Boot. If you want to disable it permanently just replace this code and set it to false.
app.json:
"loader": {"cache": true},
then:
sencha app refresh
it may seem confusing, but the _dc parameter then won't be present anymore - at all.

Get Sencha Touch Platform Name

console.log(Ext.os.Name)
prints the name for OS("Windows"==>in windows machine) for all browser,
But I want to know there is anyway to get the current Platform("chrome","safari","firefox","windows","ios","ios-classic") value based upon the theme currently loaded by sencha.
Because i need configure some of my component based on the browser also.
I dont need Browser name or os name, i need the platform variable used
by sencha framework. like when we using the ios6 it will take the
platform parameter as ios-classic we also pass the platform parameter
in link like http://cdn.sencha.com/touch/sencha-touch-2.3.1a/built-examples/kitchensink/index.html?platform=ios-classic# or
http://cdn.sencha.com/touch/sencha-touch-2.3.1a/built-examples/kitchensink/index.html?platform=windows# this will load the ios6 and windows theme respectively even we use any kind of browser in any OS.
you can use Ext.browser
console.log(Ext.browser.name);
console.log(Ext.browser.version);
Ext.device will not work for browser as it works only for native packing.
you can get what theme is applied by using Ext.theme.name
Ext.theme.name
getting platform for them is not directly provided in Sencha Touch. you can check implementation for that in sencha\app\microloader
I found the following configurations on http://docs-origin.sencha.com/extjs/4.2.2/#!/api/Ext , from that what i have observed is, we can't find the browser's name but we can check whether it is chrome or else like that...
example :
console.log(Ext.isWindows);
true //because i am working in windows
chromeVersion
firefoxVersion
ieVersion
isChrome
isFF10
isFF3_0
isFF3_5
isFF3_6
isFF4
isFF5
isGecko
isGecko10
isGecko3
isGecko4
isGecko5
isIE
isIE10
isIE10m
isIE10p
isIE11
isIE11m
isIE11p
isIE6
isIE7
isIE7m
isIE7p
isIE8
isIE8m
isIE8p
isIE9
isIE9m
isIE9p
isLinux
isMac
isOpera
isOpera10_5
isSafari
isSafari2
isSafari3
isSafari4
isSafari5
isSafari5_0
isWebKit
isWindows
name
operaVersion
safariVersion
In Sencha Touch 2.3 the Ext.device.Device singleton will give you information on the platform and the Ext.device.Browser will give you information on the browser.

CakePHP 2.1 Asset Compress Plugin not creating cached files

I'm using the CakePHP Plugin AssetCompress (v 0.7) which works fine, except that it doesn't cache any files in the directory. This is my asset_compress.ini setup:
[General]
writeCache = true
cacheConfig = false
alwaysEnableController = true
debug = false
[js]
timestamp = true
paths[] = WEBROOT/js/
cachePath = WEBROOT/cache_js/
[speedtest.min.js]
files[] = speedtest/speedtest.js
Additional notes:
I set debug to "0" in core.php
the cache_js folder is writeable (777)
also I'm using MemCache as a caching engine (not sure if this might cause the issue)
Has anybody experienced the same issue with the Asset Compress plugin?
Update: This is what I use for the CSS/Less part, works pretty well: https://github.com/Hyra/less
If I understand well this Github's wiki page you should change cacheConfig = false to cacheConfig = true to take advantage of MemCache.
You have to generate the files using the shell script. The files are not automatically generated.
https://github.com/markstory/asset_compress/wiki/Shell
To generate and store static assets defined in the asset_compress.ini config or through the AssetCompress helper on the fly. This is to save you having to manually run the console script everytime you change you css or js files.
This is what some will define as a "nasty" hack, I call it a working solution. It simply runs the console script via the php exec() method every time the AppController beforeFilter() runs and the debug level is greater than 0. So in production where your debug level should be 0, the exec() won't be run.
Add the following to your /app/Controller/AppController.php beforeFilter() function.
if(Configure::read('debug') > 0){
exec(APP.'Console'.DS.'cake -app '.APP.' AssetCompress.asset_compress build -f');
}
This is assuming that you can run the normal AssetCompress from the console (linux) or cmd prompt (windows)

Resources