Android Studio Log - android-studio

Is it possible to view just the log output generated by my application. I know I can use Log.i etc. but that only applies to items specifically logged. Often during an exception, I struggle just to read the text as the logs keep filling up with system events

If you only want to filter on your application's specific log events, simply enter the package name of your app into the filter (the search box) for the LogCat. Additionally, change the log level to Error (to avoid seeing informative messages).

Related

How can I change the log level on the fly with tracing?

As a developer I would like to adjust the log level on the fly. For example, I don't want to log debug! events when everything is going fine, but when something happens, I would like to adjust the log level without restarting the application to change the log level. I check the documentation and can't find an example there, so I want to know if it is possible to do that.
// how can I change the max_level of subscriber after it was initialised?
let subscriber = tracing_subscriber::fmt().with_max_level(Level::INFO).finish();
tracing::subscriber::set_global_default(subscriber);
debug!("some log message");
You can use reload handler exactly for this. Save remote handler in some global state and call it to change log level. See example under "Reloading a Filtered layer"
Use log4rs instead. It reads configs from a file which you can change on the fly.
I use it in one of my projects, it works like a charm.

Windows 10 Event Viewer ID description problem

I've looked at so many articles in the past year without finding an answer, I'm starting to go crazy...
I do a lot of application support and use the Event Viewer on a regular basis. On any machine but mine, when I look at an event with Event ID 0, the "data" part of that entry is shown in the General tab of the viewer. This is the default behavior that I like. On my laptop, however, for about a year now, Event ID 0 shows as "The operation completed successfully." I no longer see the "data" part of the event in the General section of the window.
Example of the annoying message
The only thing I can think of, is that I added a custom description (or definition) for Event ID 0. But frankly, I don't know how I did it, if that is the case. I want to go back to seeing the "data" in there, rather than this useless message.
Does anyone know how to fix this?
While not a "fix" to the problem, I have what may be a workaround for you.
First, I can confirm that I have experienced it also--and it's been on MORE than one computer. But it has been limited to only some apps ("sources", in event viewer parlance). So I am assuming it's THEIR doing rather than ours. Your situation may be different.
But second, and until you may find a better solution, I will note also that there may well BE a useful message for you to see. If you click on the Details tab above that message, the "friendly view" of the details will readily show what the "real" message is that underlies that log entry.
See this screenshot showing a Postgres startup message that was hidden under such an "operation completed successfully" log entry.
I have seen it and other apps/sources work this way for such startup status messages, failures, errors, and more.
Like you, I lament that we should have to know to do that. It feels to me like the folks creating the code that create the event log entry are making some choice that leads to this behavior. At least now I know that I can SEE the info they are trying to share, albeit via what seems a poor choice.

How to filter uvm_info messages by type_id?

I need to filter all the uvm_info log messages by the type_id defined in it. For example, if I want to display only the uvm_info messages from a driver or a monitor, how can I effectively do it?
The UVM does not provide a mechanism to do this very easily. You would have to set the verbosity of everything to UVM_NONE from the top-level down, then go back and turn on just the messages from the drivers and monitors.
Finding al the drivers and monitors might also be difficult unless you gave specific component names, like starting with "drv" and "mon". Then you could use uvm_root::find_all("drv*",comps); and set the verbosity of those components in comps back to UVM_FULL.
It might be easier just to take the entire log file and filter the results you want using a (sed/awk/perl/python) script
How about a custom report catcher?
https://verificationacademy.com/verification-methodology-reference/uvm/docs_1.1d/html/files/base/uvm_report_catcher-svh.html
You can put this in your base test or top, then perhaps control this using a plusarg. A rudimentary example is here:
https://edaplayground.com/x/b4Fx
I think I am quite late to answer this question, however some time ago I wrote a program to filter UVM logs: https://github.com/Loneknight73/uvmlogfilter .
You can filter on, e.g., severity, id, time, component hierarchy and the message text.
That should help anyone who needs to filter verbose UVM logs.

Why do new Activities create new Windows on ChromeOS? How to constrain them to just one window?

Problem
I have a simple Android app with 3 activities: Login, Browse_Catalog, and View_Item. On ChromeOS, I expected the Activities to stack in a single window. Instead, each Activity is appearing in its own, independently managed window on ChromeOS. Why is that happening? And how do I stop that behavior?
Request
My hope is that there is some configuration detail to keep activities stacked in a single window. I've tried looking for some flag in the Intent that launches the Activity, or some setting in the Manifest, but haven't found anything that indicates this behavior is intentional, or that there is a way to disable it.
Technical Details
ChromeOS 76.0.3809.102 (Official Build)(64-bit)
Asus Chromebox
Android Studio 3.4.2
targetSdkVersion: 28
minSdkVersion: 25
jvmTarget: 1.8
Observations
No error messages as far as I can tell. Just an awful user experience with multiple windows leading the user to think there are three separate programs running.
The Activities that should be hidden on the backstack, aren't very responsive, the windowmanager allows them to be resized briefly before reasserting a z-ordering on the activities.
The windowmanager does allow me to close an Activity/window from the backstack (e.g. Browse Catalog, while Viewing Item), but then backing off from the top Activity goes nowhere.
Possible Workarounds that are Unsatisfactory
I can kind-of workaround this by making the Activities launch in full-screen, but it feels like a huge kludge. It doesn't prevent users from minimizing or resizing individual windows.
Perhaps I could do this as single activity with multiple fragments, but I don't want to invest that much work, unless I absolutely have to.
For posterity: My mistake was the Browse_Catalog Activity had a line in the Manifest
<activity ...
android:launchMode="singleInstance"
/>
This creates the Activity as a single "Task", and won't launch any additional Activities into that Task. Here's a page with more details about Activities, Tasks, and BackStack
The default behavior (aka android:launchMode="standard") is what I was expecting, so removing this spurious setting solved the problem.

How to add Nagios custom states

I am Using Nagios XI. Currently My Nagios showing three states of alerts: CRITICAL, WARNING and OK.
I want to add another custom hard state FATAL for some extreme issues like server or any of my component(Java jar component) is down. Currently we are getting the DOWN message when the Host is Down. If the component is down I am getting "URL Status is CRITICAL" But I want "URL Status is FATAL". Is that possible to add a custom State in Nagios? How can I do that?
You can't. The states are built in (along with a fouth state, UNKNOWN, which is generally used if the plugin fails for reasons that probably belong to the plugin itself, not the object being monitored).
The states are intended to mean "requires action immediately (CRITICAL)" and "will probably require action soon (WARNING)". There's nothing left which would make your FATAL state different from CRITICAL, so i suggest you use that.
If you want to pass additional information to operators, you can always do that in the text the plugin provides.
(As Nagios is open source, you could probably modify the source code to allow another state. But this would be a huge task to implement properly, make your installation incompatible with the rest of the world, no plugins except yours would support it, and you'd have to re-apply and rewrite your patches with every new version of Nagios, so i'd strongly recommend against it).
You can't add states. But if you only want to make your alerts stand out more clearly, you can modify the nagios-Stylesheets in /etc/nagios3/stylesheets/ or add custom javascript in /usr/share/nagios3/htdocs/ssi/<nagiospage>-header.ssi and highlight the respective messages from there.

Resources